Det här är en video från ett litet projekt jag jobbat på de senaste veckorna. Projektet heter “Fältrevision virkestillredning”, inte speciellt spännande namn kanske. Videon är däremot rätt cool tycker jag. Den är genererad med gource, ett litet program som kan skapa den här typen av animerade grafer från git-loggar (det kan även använda svn eller http-loggar mm.)
Den lilla gubben som flyger omkring symboliserar mig, bollarna är filer och när gubben skjuter på bollarna med laser (eller vad det ska föreställa) så är det jag som ändrar en fil. Hrm.
Det är väldigt enkelt att använda gource, även att generera videofiler (annars visas animationen bara på skärmen). Jag gjorde så här:
MySQL has a built in function called password that calculates the hash of a password for secure storage in a database. In MySQL versions older than 4.1 the hashing function was very basic so all newer versions uses the cryptograpichally secure SHA-1 hashing algorithm (twice?).
It comes as no surprise that many older databases are full of hashes calculated using the older algorithm. Fortunately it is still available under the name old_password. I needed the hashes from the old_password function but I didn’t want to connect to a database server each time. I looked up the old_password (it’s actually called my_make_scrambled_password_323 internally) from the MySQL source code. It’s written in C so a rewrite in PHP was pretty trivial. PHP doesn’t have the unsigned integer concept so I had to do some adding in the end to make the results come out right. It hasn’t been tested much and it probably only works for plain ASCII so use it at your own risk. Here it goes.
If you are using PHP Data Objects (PDO) and are having trouble getting UTF-8 out of your MySQL server, even though everything is set to UTF-8 explicitly, you might want to try this:
The last parameter of the PDO constructor call is the driver specific options, given as an array with key => value pairs. The MySQL driver have a “PDO::MYSQL_ATTR_INIT_COMMAND” option where you can specify a command that is executed every time you connect to the database. The MySQL specific query “SET NAMES utf8” is simply telling MySQL to use UTF-8 as the character set for our connection.