Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
ToxicFrog
Apr 26, 2008


Something like this? (source)

Takes arbitrary data as input, emits I32HEX without byte swapping, and properly uses ELAR records when handling stuff larger than 64k. As far as I can tell it gets everything right, although I haven't tested it exhaustively.

Usage: hexify [from] [to]. If to is omitted, writes to stdout; if both are omitted, reads from stdin and writes to stdout.

To make it easy to use on windows, it's wrapped in a simple C program (source) that is statically linked against the lua interpreter. I may expand that into a proper packaging tool at some point.

E: also, something I thought of only after I wrote it - is the intended input meant to be binary data, or is it meant to be an existing hex dump that you just want to add the I32HEX decorations to? Because this program does the former. If you wanted the latter that's easy enough to do as well, though.

ToxicFrog fucked around with this message at 19:42 on Feb 28, 2011

Adbot
ADBOT LOVES YOU

ToxicFrog
Apr 26, 2008


Ok, this one should actually do the thing.

windows binary
lua source
wrapper source (now upgraded into a full-featured program)

Same command line signature as the last one.

Known issues: doesn't do any sort of input validation, if you feed it a file containing something other than a hex dump you will see something like this:

code:
embed#hexify.lua:25: attempt to perform arithmetic on a nil value
But as long as you stick to feeding it plain hex dumps with no extraneous fluff (comments etc) it should work fine.

ToxicFrog fucked around with this message at 19:08 on Mar 1, 2011

ToxicFrog
Apr 26, 2008


I don't know if there's a way with windows builtins, but if you're comfortable with tail and awk (or sed), there's windows versions of them which can handle this task easily.

Something like this quick and dirty script (needs uname, awk, and tail, all of which are in the above package):

code:
# syslog.awk
BEGIN {
    "uname -n" | getline hostname;  # determine system hostname
    progname = "unknown";
}
{ printf("%s %s %s: %s\n", strftime("%b %d %H:%M:%S"), hostname, progname, $0); }

# use with this command
tail -f foo.log | awk -f syslog.awk progname=foo
Output looks something like this:

pre:
$ awk -f syslog.awk progname=syslogtest /etc/passwd
Apr 05 14:14:51 leela syslogtest: root:x:0:0:root:/root:/bin/bash
Apr 05 14:14:51 leela syslogtest: daemon:x:1:1:daemon:/usr/sbin:/bin/sh

ToxicFrog
Apr 26, 2008


Aleksei Vasiliev posted:

How dumb do you have to be to create a Do Not Call list and then let telemarketers download a complete list of every number in it :psyduck:

(apparently Canada, at least, does this)

As Achmed points out, this is really the only practical way to do it.

At least here in Canada, though, it looks like your number gets broadcast to them at the start of the two-week grace period they get, or something, because the number of telemarketing calls you get goes WAY up during those two weeks.

ToxicFrog
Apr 26, 2008


SpaceMost posted:

I couldn't get the -o parameter to work (maybe because I'm on Windows XP :eng99:) so I downloaded a program called Sublime Text and managed to lasso a developer here to help me out -- we managed to get rid of everything besides the GUI_* but now everything is in a huge block that I'll have to format into a list. Still, a lot better than before. Yeesh.

Do you mean 'you couldn't get grep -o to work, but grep works fine' or 'you couldn't get grep working at all[/fixed]'? Because if the latter, that's because windows doesn't come with it; you'll need to download a windows version (gnuwin32, MSYS, and Cygwin all have windows versions of grep).

If everything is in a huge block you need to format into a list - eg, "GUI_FOO GUI_BAR GUI_BAZ" - can't you just find-replace " " with "\n", either on the command line (sed) or in your editor of choice?

ToxicFrog
Apr 26, 2008


Something like get-childitem -recurse | foreach-object { rename-item ... } will probably work, but my powershell isn't strong enough to come up with the actual rename arguments.

ToxicFrog
Apr 26, 2008


Stonefish posted:

Okay, I'm assuming complete bastard at this point.

The HTML part is a five minute task. The actual program backing it (and associated web server infrastructure it runs on) is the ugly part.

As webapps go this is pretty simple, but I still wouldn't classify it as "tiny" on the grounds that any webapp is a colossal pain in the rear end.

ToxicFrog
Apr 26, 2008


LittleBob posted:

(Basically, this company has switched to VoIP, and in the process has lost their fax machines. Whilst I could get them an analogue adaptor so they could still fax, I'd like to avoid that. They can fax by sending attachments to <faxnumber>@nul.com or whatever, so I'd like to automate the process.)

Wouldn't it be easier to just send the email directly using an SMTP library rather than invoking Thunderbird to do it?

ToxicFrog
Apr 26, 2008


peepsalot posted:

This is less of a request for an app, and more request for suggestions on what languages/libraries/etc you might use to build a specific kind of app. I wasn't sure where else to ask general programming thing like this.

The general programming questions thread is generally a good place for general programming questions. :)

quote:

I would like to make a simple GUI based application that does some web scraping. basically load up a couple pages that are on servers which I do not control, and grep the source for some particular textual data that the user can specify. My first thought about this sort of thing is to just go with HTML/javascript, as that is the one sort of GUI thing that makes most sense to me, and Javascript is already geared towards handling HTML docs, but then I cringe once I start thinking about jumping through all these hoops to get around javascript cross domain protection crap. So what would you guys use for something like this?

Depending on how robust the HTML handling needs to be, I'd probably use either Lua (with iup for the gui, luasocket for networking, and some simple regexes for scraping) or Python (with tk for the gui and HTMLParser for the parsing).

If it got sufficiently complicated I might move to Scala, but that's not one of the languages you listed, and from what you've described here it probably wouldn't get big enough to warrant that anyways.

ToxicFrog
Apr 26, 2008


.swf (ShockWave Flash) is the Flash file format. Most likely each subject just has a .txt file for the text part and a corresponding .swf for the video in some format Flash can play.

See if the .swfs will open in an external flash player. If so, the quick and dirty solution is just to use the ipad's text editor/viewer to read the .txt file, then use its flash player to open the .swf.

ToxicFrog
Apr 26, 2008


quote:

If it's not fullscreen, and this is where it may be tricky (impossible?) is to strip out the toolbars and tabs of Chrome and just have a titlebar, and that's it. You can't navigate elsewhere - it just opens the address that is specified in a config file.

WebKit is just the rendering/layout engine; stuff like the address bar and menu bar is added by Chrome (or whatever browser is using WebKit), it's not part of WebKit itself.

I think this would be pretty simple to do but I haven't really looked at the WebKit API and I'm not sure how complicated it is to use. I may take a look at it and report back.

E: :suicide:

ToxicFrog fucked around with this message at 18:52 on May 15, 2012

ToxicFrog
Apr 26, 2008


Hogburto posted:

Is making a duplicate file finder a little too large in scope for this thread?
Others exist and work, but the best one I can find gets an md5 from every single file under a directory instead of only getting the md5 of files that have matching file sizes in the first place. It takes an unnecessarily loooong time. Ironically, it has an option to ignore files with sizes below X.

What OS?

ToxicFrog
Apr 26, 2008


Hoborg posted:

Enjoy.

http://bit.ly/MPeA6V

Sorry I beat you to it, ToxicFrog.

No worries, I decided to use this as an opportunity to learn Clojure and the .NET build process and got kind of bogged down in working around the fact that (file-seq) follows symlinks.

I may finish it anyways just for fun, though.

E: decided to prototype it in the JVM first, turns out File.canRead doesn't actually work :suicide:

ToxicFrog fucked around with this message at 05:07 on Jun 25, 2012

ToxicFrog
Apr 26, 2008


Moey posted:

Since I have not done any java programming in the better half of a decade, I figured I would put this out there.

What I am looking for is a little stand alone app that can run on Ubuntu 12.04 that when double clicked, will open a small window with with a pre-set message (legal notice), then have three text boxes. One for user name, password and PC name. Once those fields are populated and they press the login button, it will launch rdesktop from command line with those values added to the correct switches.

Since nothing will be stored, I don't think there should be any security issues with it, but if there are, someone please let me know.

...does it have to be in Java?

Also, is it allowed to depend on anything in the repositories, or just stuff that's installed by default?

E: also, is there a reason it can't just display the legal notice, then launch one of the existing rdesktop frontends like grdesktop, tsclient, or gnome-rdp? Or are those too complex for the intended audience?

E2: also, if this is a multi-user system, sending the password to rdesktop via command line is a security risk; are you sure you don't want to just let rdesktop prompt them for the password automatically?

ToxicFrog fucked around with this message at 00:30 on Jun 26, 2012

ToxicFrog
Apr 26, 2008


Moey posted:

Could depend on other things, for the purpose of these builds we already have openJDK installed, I just assumed Java would be the simplest to do this in.

I would like it to be as straight forward as possible since I have some "special" users.

The reason I would prefer to handle the legal notice, UN and PW before the RDP session connects is because these are doing rdesktop spanned across 2 monitors, and since rdesktop doesn't have the same features as MSTSC 6.0/6.1, it cannot do true multiple monitor mode, only span. This means if they just connect, the legal notice, UN and PW all end up right between the two monitors, making it look ugly and possibly confusing for the end user.

These are single user systems. All they are being used for is to connect to a VPN then rdp into a virtual workstation.

In that case here is a dirt simple bash implementation. Download, make executable, double-click. Uses zenity, which should already be installed - if not just "sudo apt-get install zenity". It is (hopefully) obvious where to edit in the window title, rdesktop options, and legal notice you want.

Due to limitations in how zenity works this asks the questions one after another, each in their own window; if you need it all in one window I can toss together a python version that does that instead.

E: there's also no error checking, eg, it'll happily proceed and let rdesktop complain if "username" is left blank. If you do want to go ahead with this version, I'll add that.

ToxicFrog fucked around with this message at 01:05 on Jun 26, 2012

ToxicFrog
Apr 26, 2008


Moey posted:

Awesome! I will do some testing tonight or tomorrow. Thanks.

I was doing something similar, but wanted to have the nice little GUI which is why I figured Java. Never knew about Zenity.

For simple "fill out a form" type stuff, it's generally way faster to do it in a scripting language with builtin bindings to a small gui library. Python/Tkinter and TCL/Tk come to mind; neither is my favorite language, but Tk is nice and simple and both are pretty much standard on linux (python especially).

For even simpler question-and-answer things, zenity is fine. It's incapable of anything more complex, but sometimes that's all you need.

ToxicFrog
Apr 26, 2008


Moey posted:

Hmm. To get the text input boxes on the same window, would I have to move to something a little more powerful?

Yes.

Someone more experienced with Python could probably tighten this up some.

ToxicFrog fucked around with this message at 03:36 on Jun 26, 2012

ToxicFrog
Apr 26, 2008


Moey posted:

Sorry to be such a pain, but how do I launch this?

Copied your script to a file on the desktop called rc.py. Went into terminal and made it executable (chmod +x rc.py). When I go to run it, I am not seeing anything happen. Looks like the base install of Ubuntu 12.04 does have python.

That should work fine. What happens when you try running it from the terminal (./rc.py)?

I don't have 12.04 handy right now to test on, so my best guess is that either (a) it doesn't come with tkinter by default (easy to fix with apt-get) or (b) it's defaulting to python3 rather than python2 as earlier versions did, which will require some minor changes to the program.

ToxicFrog fucked around with this message at 17:58 on Jun 26, 2012

ToxicFrog
Apr 26, 2008


Moey posted:

You rock. ./rc.py showed that it was missing tkinter. apt-get install python-tk fixed that up real good.

This may be geared to the linux thread, but is there a way to get Ubuntu to just directly launch the python script without all the extra options?



Or change the image for it, so it is not the little script/text symbol?



Somewhere in Nautilus there's an option to change this globally (for all python scripts, or possibly for all scripts of any kind). You probably don't want that, though.

What you probably do want is to create a .desktop file, like this:
code:
[Desktop Entry]
Name=RDesktop Launcher
Comment=Asks some simple questions and then runs rdesktop
Exec=python /path/to/rdesktop-launcher.py
Icon=applications-internet
Type=Application
Categories=Network;Utility
Terminal=false
Edit as needed, save as /usr/share/applications/rdestop-launcher.desktop, and it should show up in the applications menu (under the listed Categories).

ToxicFrog
Apr 26, 2008


TysonR posted:

I'm hoping this might be a tiny custom app but if it isn't just ignore.

A program in C++ [for windows] that takes 2 string inputs and sends POST data to a URL. The URL will return content with 1 or 0, which the program needs to display Valid if the response was 1 and Invalid if 0.

The test web URL is at: heytysonray.appspot.com/verify
post data is labeled as "email" and "license".

A valid combination that will return a 1 is a/a

Does it have to be C++?

Moey posted:

You seriously rock! The amount of googling the wrong terms I would have done to figure that out would have been embarrassing.

I have all the answers because these are all things I've banged my head against in the past (and spent embarrassing amounts of time figuring out). ;) I hope the app works well for you.

ToxicFrog
Apr 26, 2008


Scaramouche posted:

Couldn't you just do this in shell script (Perl, Bash, .bat, powershell) and something like cURL/ncat?

I was going to do it in lua so it could be contained in a single file, but yeah, those would also work just fine. Hence my question about whether it has to be C++.

ToxicFrog
Apr 26, 2008


Hoborg posted:

My homeworksense is tingling.

I suspect the OP is tasked with some C++ coursework for making web-requests, and by having a simple bare-bones implementation provided for him he can flesh it out as needed by the assignment dictates.

However, it's June. Academic season is off... so maybe he says "C++" because he wants something native, as opposed to something that runs on Python, the JVM, or the CLR.

From an end-user perspective, though, there's no difference these days between a CLR app, a native app, and a py2exe/enceladus/etc script + embedded interpreter.

ToxicFrog
Apr 26, 2008


TysonR posted:

I'm requesting C++ because I would like to integrate this functionality into a program that is already written in C++. I think I could do this after playing around with urllib2 in python, but the program that this would be put into is in C++, and googling and asking around about the best way to implement this in C++ is still leaving me with more questions than answers. Hence, I figure if this app can be done in a small amount of time it would be a lot easier for me to understand it from the source code.

The end-result is that I am basically trying to integrate a license check that pings my url, and have my url respond back from checking a cached database to see if the entered license key was valid, and if valid have the program unlocked/return as registered.

This is pretty fragile even for DRM, but at least it's easily bypassed, so there's that.

If you control the authentication server as well, switching to GET instead of POST will make your life a lot easier on the client side as you can construct an appropriate GET query in just a few lines even without using libcurl or something, whereas POST, in my experience, is a pain in the rear end whether you're using an http library or not.

ToxicFrog
Apr 26, 2008


Hoborg posted:

Uhm, how? I'm genuinely curious.

code:
fields = {
  user = "me";
  license = "123456";
}

request = "GET /license.php?"
  .. fields:mapkv(f 'k,v -> urlencode(k) .. "=" .. urlencode(v)'):concat('&')
  .. "\r\n"
  .. "Host: www.whatever.com\r\n"
  .. "Accept: text/plain\r\n"
  .. "Connection: close\r\n\r\n"

sock:write(request)
It's uglier in C/C++ but still pretty straightfoward. If you're using an HTTP library it gets even easier, because in most libraries you just end up with something like:

code:
http.request("GET", "www.whatever.com", "/license.php", fields)
In contrast, with POST you need to faff about with generating unique separators for the various fields and setting the content-type properly and whatnot, and I have never seen an HTTP library with a POST module that wasn't absolutely miserable to use.

ToxicFrog
Apr 26, 2008


Jiblet posted:

Sorry, should have said - I'm trying to use the extra keys on a Microsoft Natural 4000 keyboard (the "My Favorites" buttons specifically which I don't use at all and don't want to use). The drivers will let me use assign the button to a keypress or to fire off an application.

So in this case I use the media keys to fire off a compiled AHK script that sends key presses to Spotify for next/prev track etc. And I'm trying to extend this functionality to TS3 mute (and alter to set away/back)

...since you can already set the media keys to send other keystrokes, why not just have them send the keystrokes that are already bound to "TS3 mute" and "TS3 toggle away"? Why does AHK have to get involved at all?

ToxicFrog
Apr 26, 2008


pipes! posted:

Not so much an app as much as an Alfred extention, but I have this half-baked piece of Bash:

code:
echo "scale=3; {query} / 16" | bc
echo $em | pbcopy
It's for a script to convert pixel values to ems, something I have to do a lot for web development. Basically, I'm trying to wrap up the first line into the variable $em, so I can copy it to the clipboard. However, I've hit a wall since I don't know Bash at all, or its syntax - this was more or less cobbled together through trial and error.

If it helps any, {query} should be escaped via the spaces.

I have no idea what you mean by "{query} should be escaped via the spaces".

For the rest of it, though - variable assignment in bash is just name=value. The value you want here is the output of the echo|bc, which you can get using $() ($(cmd) runs cmd and expands to the output of that command), something like this:

code:
em=$(echo "scale=3; {query} / 16" | bc)
echo $em | pbcopy
If that's the only thing you use $em for, though, you don't even need the variable; you can just pipe the output of bc straight into pbcopy:

code:
echo "scale=3; {query} / 16" | bc | pbcopy

ToxicFrog
Apr 26, 2008


madeupfred posted:

This is a really tiny and kind of stupid, but I would be willing to pay for an app that takes the County Results by state at http://www.politico.com/2012-election/results/president/(Insert State Here)/ and saves them in an Excel workbook.

Arranged how? Same way as on the site, with county - candidate - party - %votes - nvotes, and multiple rows per county?

ToxicFrog
Apr 26, 2008


juche mane posted:

After reading about what they did to Oracle, I don't think I'll be giving these Libre Office people a lick of my support. I think I might just wing it, this thing is the size of a hand-ball so I think the weight/volume be damned, I'll just drain it tonight and see how it goes.

:psyduck:

Ok, I know I'm probably going to regret this, but I'll take the bait: what, in your mind, did the LibreOffice devs do to Oracle, and how is using LibreOffice "supporting" them (given that it's free software that they don't even get ad revenue from)?

ToxicFrog
Apr 26, 2008


pipes! posted:

I was wondering if it's possible to alter my .bash_profile to have the prompt display a special character when I'm in a specific directory or it's child subdirectories. Something that would look like:

user@host ★ favorites/foo/bar $
user@host ♬ music/ $
user@host ✎ documents/foo $

etc.

Totally. You can embed $(...) sequences in your $PS1 and they'll be executed when the prompt is displayed, so you can do something like this:

code:
ben@thoth:/tmp$ echo $PS1
\[\e]0;\u@\h: \w\a\]\u@\h:\w\$
ben@thoth:/tmp$ function __ps1_diricon() { [[ -f .diricon ]] && echo -n " $(cat .diricon) " || echo -n ":"; }
ben@thoth:/tmp$ export PS1='\[\e]0;\u@\h: \w\a\]\u@\h$(__ps1_diricon)\w\$ '
ben@thoth:/tmp$ echo -n '&#9836;' > .diricon
ben@thoth &#9836; /tmp$ echo -n '&#9731;' > .diricon
ben@thoth &#9731; /tmp$ rm .diricon
ben@thoth:/tmp$ 
This version won't work in subdirectories, but I'm writing up a longer one that will.

E: here you go:

code:
function __ps1_diricon() {
  local dir="$PWD";
  while [[ "$dir" != "/" ]]; do
    [[ -f "$dir/.diricon" ]] && {
      echo -n " $(cat "$dir/.diricon") "  # output .diricon contents padded with spaces
      return
    }
    dir="$(dirname $dir)"
  done
  echo -n ":"  # output default ":"
}

export PS1='\[\e]0;\u@\h: \w\a\]\u@\h$(__ps1_diricon)\w\$ '
Put that in your .profile (or .bash_profile if you use that instead and you should be good to go. It'll look for a ".diricon" file and use the contents of that, surrounded by spaces, as the icon for that directory and all subdirectories. If there's no .diricon it'll default to ":".

If you want to change the prompt, just change the value of $PS1, but this should match the example you gave.

ToxicFrog fucked around with this message at 01:38 on Apr 10, 2013

ToxicFrog
Apr 26, 2008


Happiness Commando posted:

Anyone willing to make a tiny app that will play an mp3 or wav file every X or X + rand(Y) minutes without any intervention?

What OS, and is it going to play the same file each time or does it need to go through a list?

ToxicFrog
Apr 26, 2008


Masked Pumpkin posted:

I've got a Windows 2012 server with a bunch of files (400 000+) that need to be transferred to a new server. FTP has been set up, and that whole process has been smooth, except that hidden in those folders are a number of files with a space in the front: " sms.pdf", for example.

These files don't transfer happily as Windows simply doesn't like spaces in front of file names.

Are you sure the problem is windows and not whatever software you're using to do the transfer? Win7, at least, is a-ok with filenames that have leading whitespace.

Adbot
ADBOT LOVES YOU

ToxicFrog
Apr 26, 2008


Uncle at Nintendo posted:

If someone could please help, it would be greatly appreciated. This with the combo of a baby who is teething is giving me some pretty bad sleep deprivation so any help would be literally improving my quality of life. :D

Here you go. Based on nircmd.

Unzip somewhere, double-click raccoons.bat, enter how many minutes you want it to mute for. Press any key to unmute early.

  • Locked thread