dynamic CSS background images
Include the 'fake' CSS file...
<link type="text/css" href="css/style.php">
Build the 'fake' CSS file...
HTML GO!
<h2 class="something"><span>Something</span></h2>
BOOM!
headers/something.png will be set as the header's background image.
June 2, 2010 [17:26]HTML5 Testing: Video
Using the new HTML5 <video> tag and the Video For Everybody no Javascript embed method.
See also: the video chapter of Mark Pilgrim's Dive Into HTML5 book for info regarding video encoding methods and more advanced embed options for browsers not yet supporting the <video> tag.
May 19, 2010 [15:12]resizeEmbeds
Takes a string of HTML and resizes all of the embeds/objects to a specific size. Handy for resizing videos to a specific size.
May 13, 2010 [23:17]getTimeDiff
If $loop is set to true, the format returns as: 3 hours 24 minutes 15 seconds.
If $loop is set to false (or left as the default), it returns as: 3 hours.
unfollow everyone!!!! (on Twitter)
PHP/API hook-in to unfollow EVERYONE that you are following on Twitter. Start fresh!
February 18, 2010 [15:29]last fm recent tracks
Here is a simple little PHP snippet I use to display the most recent tracks from my Last FM profile. The example below prints in a similar format to the list I have started including on the homepage.
Notes:
- This uses the curlContents function that you can grab from here.
- This also uses the PHP5 json_decode function. Peeps with older versions of PHP will need to either hunt down an alternative or UPGRADE!
- You will need to replace the YOUR_USER_NAME and YOUR_API_KEY values (obvs)
- $cache_file is the absolute path to a cache version of the html that is created. The file will need to have the usual read/write permissions.
- In this example I check to see if the cache file has been updated in the past 10 minutes (ie. 600 seconds) and if not - I update it. There is also a built-in $force_update to assist with testing.
cURLs get the gURLs
Simple little function to cURL a remote URL, with the option to also post an array of data.
January 19, 2010 [11:06]