Archive for 2012

my contribution to the grumpy cat meme

all hail the latest meme to capture the hearts of the internet: grumpy cat:

Grumpy-Cat-MEME-01

so here’s my little sketch:

grumpycat

download the pdf to print out!

Read the rest of this entry »

chiddy

so i’m heavily listening to these two songs by chiddy bang. xaphoon jones you crazy, crazy crazzeee

ray charles

that’s the jam!

mind your manners

php: randomly picking a variable to display for a week

so i built a random name generator for andy’s site… it’s meant to show a name for one week, when that week is over, a new name will appear.

it’s super manual — every year, he has to run a script that will randomly generate the list for the year

now that i know a little bit more php, i’m wondering if there’s a way to have it randomly choose a name from a database and display that for one week. the “one week” part is the toughest.

surprisingly, i’ve already set up a plugin where he’ll be able to add, remove, edit names easily via the wordpress admin. all the names are in a nice database.

now to display a randomly generated name for a given week… halp?!

wordpress: get post slug

originally found this on josh stauffer’s site. just wanna add to my site so i can pull it up easily

$slug = basename(get_permalink());

php: modifying a filename

needed to do this to make wordpress choose the thumbnail image instead of the full-sized image — since some people like to upload gernormous images (recall that wordpress uploads a whole set of images when you upload one)

so this adds a suffix (in this case, “-150×150”) to the of the filename, BUT before the file extension

anyway, here it is:

// set your suffix
$thumbnail_suffix = "-150x150";

// $featured_image is the filename. this would be determined above this code snippet
// determine the length of the filename, including the extension
$length = strlen ($featured_image);

// get the first part of the filename (before the extension)
$temp1 = substr ($featured_image, 0, $length-4);

// get the second part of the filename (the extension)
$temp2 = substr ($featured_image, $length-4, $length);

// stick the suffix in between the two halves
$featured_image_updated = $temp1.$thumbnail_suffix.$temp2;

you might be saying, “but joey.. why don’t you just use something like explode to break up the filename?” well you really don’t know what the filename will be — it could have a bunch of dots in it… if you could figure it out, great. let me know what you did.

at least you know every image file that’ll be uploaded will be a “.” and then three characters after.