Monday, July 28, 2014

angular edit-in-place

http://jsfiddle.net/joshdmiller/NDFHg/ is a decent little angular.js "edit in place" - i.e. it's a span, click on it for an edit box

Sunday, July 27, 2014

the joy of exif

This is just a rant. I hope to do a followup post once I fix the damn problem.

Man, EXIF and iOS and browsers == bad, bad news.

So, iOS doesn't bother to actually rotate a JPG when it stores it in memory, just notes which way the camera was held in the EXIF metadata, and sophisticated display programs do the right thing to show you your image right way up. Fair enough, I guess, rotating big chunks of memory is hard work for a device.

BUT -- Chrome Safari and Firefox ignore the EXIF when it's a jpg in an img tag, so the images appear at all kinds of random orientations, but then they respect it when you open up the image by itself in a tab. (!!!) IE just always ignores it. So points for consistency for IE.

http://alienbill.com/kirkdev/exif/raw/view.html if you want to see this wonderous magic for yourself.

I was all psyched about my this drag and drop image upload library I found (  http://www.dropzonejs.com/ ) but now I have to figure out how to get ImageMagick to fix this crap before I can enjoy the fruits of my labor. This is really horrendous.

salvaging old laptop HDs

PROTIP: If you have an expired PC laptop and want its harddrive (either for retrieving files or for cheap disk space) you can get a USB enclosure for small money. This one runs about $7 and comes with everything you need, even the USB cable and tiny screwdriver.

Saturday, July 26, 2014

tree - nice recursive directory lister

There's a useful Terminal command called "tree" that you can easily install on a Mac (if you have Homebrew installed, at least.) It's like a variant of "ls" that produces a nice hierarchical view of a parent folder recursively on down.

If you have brew, just type

brew install tree

And there you have it.

PROTIP: you can also tyoe

brew list

to see what software has been installed using it.

Tuesday, July 22, 2014

parkie, the power of simple javascript

Years ago I lived in a neighborhood in Boston that had annoying alternate-side parking rules: something like the 1st and 3rd Wednesday had street cleaning on the right, so park on the left, and the 2nd and 4th Wednesday was the reverse. (I guess this was defined more in a "even/odd #'d side of street" kind of way, but the street was one way, so left/right made more sense.)

It was a fiddly thing to deal with... recalling the date, figuring out the date of the next Wednesday, figuring out which Wednesday of the month it was, remembering which side that implied, etc so I made a Javascript page for it: http://kirk.is/tools/park/ . Super minimalist, it just does the thinking and prints the results, but it "shows its work" so to speak so you can see the reasoning and confirm it for yourself.

My cousins now live in that house, and I revived it (and updated, the day of the week had changed, actually) and gave them a shortcut to the page on their iPhone's homescreen. (In theory I could also have made it a Bookmarklet, which would let it work "offline", though I don't think you can put those on the homescreen, and it's not like these phones are offline that much anyway.)

I like tiny bespoke projects that make life notably better. (This one reminds me of the kind of programming people would do in BASIC on old 8bit computers, but modern portable tech and ubiquitous networking make it much more convenient!)

Friday, July 18, 2014

semi-opaque backgrounds without semi-opaque control

My company did a Hackmatch/Hackathon last night. I ran a one-man team converting a dynamic Excel spreadsheet (meant for helping a scrum team plot out its hours and make commitments) into a one webpage app; partly for me to practice Angular, partly because I'm now scrummaster and I dislike using Excel.

I needed a trivial back end for the scripts, and found that the old simple Python webserver has a version that can also run CGI scripts -- the command is
python -m CGIHTTPServer 8081
You can then create a cgi-bin/ folder, and files under that are eligible to be executed once appropriate permissions are set. One slight oddness is that path references are relative to (I think) where the python command is run, not the location of the script. I started coding in Python (a language I barely know, but I was just doing simple things) because at some point my sleep-deprived brain thought maybe I had to, but later a Perl script slotted in neatly as well. (I had some trouble because Angular fundamentally wants to POST in JSON formats, and Python fundamentally wants to read POST info as good ol' x-www-form-urlencoded, and while both can probably be persuaded to go the other way, at that point I was too tired to sort it out, and so I recycled an old jQuery/Perl pair I had previously written.) 

Anyway, looking for a bit of visual distinction, I threw in a large photo of a Rugby Scrum as a background, but of course then the risk was making things dificult to read. I set the various sections into background divs (inline-block'd so they were sized to hold their contents, not full browser width) but then I wanted to set the opacity, so they didn't block out the cool background. But I didn't actually want the controls to be opaque! What to do?

There seem to be some hacks to try and do it via pure CSS, but they didn't work for me. I realized I could set a repeating background PNG of a semi-opaque pixel. A suitable one can be found at the Wikiedia Commons. (The link is under "no higher resolution available"... I left clicked and then hit cmd-S to save the little bugger.)  My CSS was then 
.section {
    background-image: url("Translucent_50_percent_white.png");   
    display: inline-block;
    padding: 10px;
    border-radius: 10px;
}
I'm pleased with the result! I have only meager graphics design skills, so I like tricks like using an oversized photo, easy, underutilized hacks to make a page standout.