Posts Categorized: Programming

A Script A Day – Day 02/05

Continuing along, day 2’s task was to get stock quotes.  Usually a pretty simple task once you find a data source to use.  I settled on using YQL to query Yahoo Finance.  This one has a few requirements (wget, hexdump, xsltproc) as bash is a bit limited.

Continue reading

A Script A Day – Day 01/05

I had an idea for a programming self-challenge.  From Monday, Sept 1st to Friday, Sept 5th: I’ll write a new script each day.  The goal should be simple enough to solve in one day, but not so boring I’d feel dumb writing about making it.  I’ll likely be sticking to business logic type goals, as I don’t actually enjoy algorithmic challenges as much.  Now if a practical goal requires a decent algorithm, then so be it.

Continue reading

Script Encrypt

Have you ever wanted to encrypt a script so that it could only be run with the correct password?  Chances are… probably not.  However, in the off chance that you have, and your script is perfectly happy being piped through it’s interpreter (* See note below), then this script might work for you.  I make no guarantees or claims about how secure it might be, and it requires openssl to be installed to work. You can view the code or download it yourself at my BitBucket repo for Script Encrypt. Continue reading

Image Color Dominator

Most anyone who’s used iTunes’ album view will know about their color picking mechanism.  I was curious about how this might be done and found this question on Stack Overflow: How does the algorithm to color the song list in iTunes 11 work?

So I set about creating an equivalent in PHP.  I settled on using the IMagick PHP extension for grabbing pixel data and doing blurs.

The Results

mizu Mizu (Water)

moon Tsuki (Moon)

fall Aki (Fall)

Chibi Chibi ^_^

The How

It’s largely based on the accepted answer given on the Stack Overflow question mentioned earlier. Except I separate potential highlights from the selected background based on a luminance ratio which produces more readable text, and there’s some additional logic for trying to pick contrasting highlight colors.

The Source

Source is available on BitBucket: https://bitbucket.org/epb9000/image-color-dominator/ Not much in the way of documentation, so hopefully the comments on the class aren’t horrifically confusing. I’ll re-read them later and maybe make changes.

Ludum Dare: Marvie!

I produced an entry for this month’s Ludum Dare. It’s a traversal memory game where you have to find your way back home, but you can only pick one path forward, picking wrong forces you to reset.

A brief description:

Marvie is spacefaring alien and can only travel along asteroids. But Marvie has a problem.

He kind of disintegrates every asteroid he touches. He can’t help it. His psychologist says the condition will only get worse with age. How tragic.

Marvie!

Link to Play: http://iris.kiristar.com/mv3/
Link to Source: https://bitbucket.org/epb9000/marvie/

Implemented almost entirely in JavaScript, this uses the DOM to render the playing area.

Anchor links in TCPDF

A question was posed on StackOverflow regarding html anchor links like ‘#test’, and how you might go about preserving them.  However, it got deleted before I could post my answer.  This is current as of today, May 22, 2013.

If you are using a version of TCPDF less than 5.9.193, links that start with `#` need to be changed to reference a page number and, optionally, Y position.  For example, `#3,4.5` to jump to page 3 at position 4.5.

As of 5.9.193, you can link to named destinations with html links this way.  However, for this to work, you need to add the named destination yourself with the `setDestination` method. [1] So with the example of `#test` you’ll need to have created a named destination called `test` with `setDestination`.

For an example of how this might be used, see the feature request that got it added: Feature request #265 HTML href link to destination or bookmark

[1.] As far as I’ve experienced, these do not seem to work in Firefox’s current PDF.js reader however.