Category ArchiveCoding



Coding 23 May 2008 02:40 pm

Me, talking about the Photobucket API

I post a lot of videos here by other people (that I find funny or otherwise interesting), but someone filmed ME this time! Check out the Channel 9 post, and view the video.

Coding 23 May 2008 12:49 pm

Two Mac OS X related Issues and Fixes

I use Mac OS X 10.5 (Leopard) for all my work tasks.  I do, in general, love it, but as with all applications or OSes, its got some bugs and idiosyncrasies.

I noticed after upgrading to Leopard, OS X stopped automatically attaching to wireless networks I’ve logged into before, and said ‘remember this network’.  I loved that behavior as I could just turn on airport at work or at home, and connect up to the wireless.  I tried creating new connection profiles, clearing those items out of my keychain, etc etc, to no avail.

I then read this article on macnn forums.  I would link to the specific post if their forums let me, but down near the bottom, a little nugget of info finally caught my eye.  If you’ve moved your System Preferences.app file out of Applications (like, into a subfolder like Utilities), none of the wireless network saving works right.  So, follow the instructions by moving System Preferences.app to /Applications directly - delete all your current saved networks, check the keychain and remove any networks from there too, reboot, and join a new network and save it.  You’ll be able to reconnect automatically from now on.

I guess this is what I get for being a organization freak - I’ve got all my apps compartmentalized into folders cause I hate having to scroll thorugh lists of apps (I do the same thing on my windows machine too).

The other thing I was dealing with was Entourage.  Entourage (even 2008 with the latest service packs) doesn’t have an autoarchive function like Outlook does.  This makes the Exchange overlords unhappy and they start locking your account for going over the storage limit.  On Tiger and Entourage 2004, I was using the autoarchive applescript from the Entourage Help Page on mvps.org.  It worked all fine and dandy until I upgraded.

This autoarchive applescript file is based on that script, but updated to work properly with Leopard and Entourage 2008.  It is set up the exact same way as the script from mvps.org (Drop it on your machine (~/Library/Scripts seems to be a good place), add a schedule in Entourage to run that applescript). Be aware, it does use the Spotlight search feature - so if you get errors about missing messages, be sure to run the ‘Rebuild’ from the Entourage->Preferences->Spotlight menu.  If you want to configure the number of days it archives back from (it’s currently set at 15 days), you can edit the scpt file and recompile.

Hopefully that helps some people.

Coding 09 Apr 2007 01:02 pm

Win32 Perl Scripts

Note, my current setup doesn’t seem to like code much - so bear with me if there are missing backslashes, or other oddities. I’m currently figuring out where to put these files so that I can just link to them

Change Desktop Win32 - Change your desktop to a random picture. The path ($path) below should be set to where you have images which you want to have randomly on your desktop (and only those files). You’ll need the CPAN package ‘Win32::API’.

The problem I’ve had with this script is that it doesn’t seem to work properly outside of the Cygwin/Bash interactive shell.

Clipboard to Browser URL Win32 - Open Clipboard URL in your browser with a Hotkey. This perl snip will read your clipboard, and open your default browser with that URL.

This might need the package ‘Win32::Clipboard’, but that package might be included in Win32::API. If you put this in a shortcut which is on your desktop or in your start menu, you can assign a hotkey (like ctrl+alt+shift+o) and it will launch this automatically. Using the rundll32, it wont leave the commandline window open.

This new version also uses the CGI::Untaint library, specifically CGI::Untaint::url (which is a seperate package). This lets it pretty generally do URLs, http, https, ftp, mailto, etc.

Coding 22 Mar 2007 10:51 am

Cygwin/Bash Tips (#1?)

Bash History
This post turned me onto the fact that the bash history is actually relatively powerful - moreso than I thought at first. You can use positional references and regular expressions much like in a vi command. The bash man page on the subject has all of the options, but no examples, which is probably why I skimmed over it before.

Screen in Cygwin
I’ve been using screen for years in linux to help manage multiple windows, and processes which I want to persist between login sessions (either long running processes that I want to be able to check in on, or things like irc which I dont want to have to disconnect/reconnect all the time). I’m sort of limited on the boxes I have access to lately, but I have the whole cygwin suite set up on my home machine, so I’m using that as a viable alternative. The bummer is, screen is not one of the officially supported packages by Cygwin. There have been a few patches and builds of screen, and the one I’ve found works the best is this version of 3.9.15.

This comes with a caveat though. For whatever reason, regular ‘reattach’ (-r) doesnt work under cygwin, but the flag to login to an existing attached session (-x) seems to always work (Thanks for the tip). So where I used to use ’screen -r’, I now use ’screen -x’ and it seems to work nicely.

[Update]: After using it for a while, it looks like a non-forced disconnect (like SIGHUP from the ssh session going away) puts it in the same state as screen -r (it’ll just sit there). Worse, it looks like it’ll detect the session as dead potentially. I’m looking into this. If anyone out there has info please let me know!

I’ve got some more tips on how to use Cygwin, but I’ll have to add those later.

Coding 08 Nov 2006 11:09 am

On Comment Spam and CAPTCHAS

This article on alternatives to graphical CAPTCHAS is pretty brief, but it made me remember my ideas for battling comment spam.

This CodingHorror entry inspired me to think up some ways of doing validation that is easy for humans, but potentially hard for bots.

  • Simple Word - a simple printout of the validation word next to an input box that the user must then replicate. This could be a word from any dictionary, or random, or some combination of the two. I don’t think this is that much less effective than an image with the same function. If you’re worried that the proximity of the word to the input is a problem, use stylesheets to randomly separate them. This still allows a real human to copy-paste the text, so it makes it real simple. Alternatively, do similar things with an image that is easier to read.
  • Randomized Form IDs - the actual entry name (variable name) could be randomized for each user - which would prohibit automated bots from just submitting blind posts.
  • Randomized Submit - I imagine a grid of buttons, all of which are submittable (but may be hidden), one of which is shown to the user and valid. Put that button randomly in that grid, with a random ID (as above), and I can’t imagine a good way of automating a submission to that. Using the button type=image is very powerful here, where hidden buttons will be a transparent image, or the same as the background, and the shown button would be unique. Using some rewrites to make sure those image names are randomized works here (where only certain ranges or checksum+salts are valid)
  • Simple Logic - any number of single-digit-arithmetic could be done with the Simple Word method above. Things as simple as 2+2=?, 8-3=? would get you pretty far, and depending on your audience, you could get more complicated.
  • Word Manipulation - Using the Simple Word methods above, do some manipulation of that word (like the word backwards, or if multiple words are used, transpose the words).
  • Time Limit - encrypt (or even just hash) a time limit on the form - if the time limit is less than that which a human would use (depends on the application, obviously), then its probably a bot.

All of these can be done without javascript, and at most require some of the more simple functions of stylesheets on the user side. On the server side, they all require some session-persistance, so cookies are required, unless you encrypt the valid data into the form (which isn’t terrible).

As with most things, a combination of many of the above is preferred - and some of it randomized (word vs logic, etc).

I’m going to look into how drupal does their captcha and see if I can build a library do do some of these things. One of the sites I have waiting in the wings will use these methods heavily (the previous run was heavily bot’ed within a week).