posts tagged with the keyword ‘mysql’

2010.07.22

I love Last.fm. I love music, and I love data, so it makes sense. Last.fm, for you unhep cats out there, allows you to keep a log of what you listen to by “scrobbling” your music – that is – it submits the info about the songs you listen to the Last.fm web site via various bits of software. There’s scrobbling clients that work with iTunes, and your iPod, and your iPhone, and other things that don’t start with ‘i’ or come from Apple. (Oh, I’m rasterweb at Last.fm)

It’s interesting to see what I listen to, and who my top artists are, and all that jazz that comes with logging data… charts, graphs, etc. Fun stuff!

But as you’ve seen, I’ve been on a kick lately to pull all that data back to my own site. (See Also: Scuttle rides again!, Tweet Nest: Archive Your Tweets, Data goes in, Data comes out., Reclaim What’s Yours… Take Back Your Data!) So I figured it was time to get the data I’ve been feeding into Last.fm since 2006 back to me, and back to my own site…. thusly “Heard” was born.

Heard

Heard is a bit of PHP code I whipped up which uses the Last.fm API to pull my scrobbled data back to my own site and stuff it into MySQL, and from there it simply displays the data. Once again, this is my insurance policy. If Last.fm goes down, disappears, loses all it’s data, or something else happens, I’ve at least got an archive of all of my listening data.

Last.fm is a great service, and they’ve provided a great API that makes doing these sorts of things possible, and I thank them for that.

So Heard is really just some hacked together code right now… I don’t think I’ve spent more than a few hours on it, but it is functional, and syncs data once per hour. Once I implement all the ideas I have for ways to improve it, I’ll upgrade my version, and think about releasing some code if there is any interest in it. I’m a pretty poor PHP programmer, but I’m dangerous enough to build simple things. If someone else loves this idea and wants to run with it, let me know, and I’ll share whatever I can.

Last.fm

And yes, the design (or lack of design) of Heard is minimalist to say the least. In one part it pays homage to Last.fm’s display of data, and in another part, I didn’t want to get too caught up in the look at this point, but I do have some plans for later.

(And one more thing: Thanks goes out to Pixis Creative for doing a bit of CSS debugging for me.)

Update: The code for Heard is on GitHub. I’d love if people smarter than myself found ways to make it better.

2010.07.11

This is what I tend to use for a simple MySQL database backup script… I wanted to post this so I can look it up when I need it. There are probably better ways to do this (tell me about them!) but this works for me.

#!/bin/bash

DT=`date +"%Y%m%d%H%M%S"`

mysqldump -u [USERNAME] -p[PASSWORD] [DATABASENAME] > /home/backups/[DATABASENAME]-$DT.dump

gzip /home/backups/[DATABASENAME]-$DT.dump

mysqlsm

Substitute your MySQL user for [USERNAME]. (There should be a space between the ‘-u’ and the [USERNAME])

Substitute your MySQL user’s password for [PASSWORD]. (There should not be a space between the -p and the [PASSWORD])

Substitute your MySQL user’s database for p[DATABASENAME].

Each time you run it, it will get the date with the year, month, day, hours, minutes, seconds, and use it in the name. So %Y%m%d%H%M%S would produce something like 20100711090854. If you are running one backup per day, you could shorten it to %Y%m%d.

This would put the files in the /home/backups directory. Set this to wherever you want the files to go.

The gzip command compresses the dumped database file. If you don’t want to compress it (and save disk space) then don’t use it.

(BTW, you don’t type the [ brackets ]. They are just there to highlight the words you need to fill in.)

|


buy the button:

Buy The Button