Twitter RSS Feed
Back in the good ‘ol days finding your Twitter RSS feed was quite easy, as it was displayed on your profile page. Now that Twitter is all grown up, things aren’t so easy anymore.
So, thanks to Google and the internet community I’ve found a current solution that I’m posting here for the sake of posterity.
1) RSS Feed URL structure: http://twitter.com/statuses/user_timeline/[YOUR TWITTER ID].rss
2) Get your Twitter ID from here: idfromuser.com
There you have it. Now plug that in to your script/class/etc.
Published on August 24, 2011UAR 2011
Did the New Belgium Urban Assault Ride again this year with my friend Chris. With a new strategy for the course route we did much better.
Men’s Class 13th
Place overall 22nd
Bib Num 116
Team: Repetition Sucks Sucks
Time: 1:46:53.2
Max lifetime for a PHP session
I was receiving complaints about a multi- page form I developed for a client. I couldn’t replicate the error, so I set out to research the ins-and-outs of PHP sessions. I’ve come to find out that any session data that is set will expire in the default setting of 24 minutes (1440 seconds) which is set in php.ini. To extend that time you have to either update the php.ini file (not a good idea) or update your script with ini_set() which will set the max lifetime for a session for your script. Simply call it on all the pages of your script with:
< ?php ini_set("session.gc_maxlifetime", "5400"); ?>
Now your users can spend, in my case, 90 minutes on the page without their session data expiring.
Published on July 11, 2011User Agent Targeting with PHP
I’m currently working on a site for a client and they have attached PDFs that open in modal windows, but have included language for users to right-click and download them adjacent to the links. I used the generic language “Save link as …” but my client couldn’t find that option in the right-click contextual dialog. So, I thought to myself, “hmm, how should I fix this for them?”
So, I wrote a quick little PHP function to produce User Agent specific “download this link” language.
function contextual_download_text(){
if(isset($_SERVER['HTTP_USER_AGENT'])){
$agent = $_SERVER['HTTP_USER_AGENT'];
}
if(preg_match('/.*?Firefox/i',$agent)){
// Firefox
$dl_link = "Save Link As ...";
} elseif (preg_match('/.*?MSIE/i',$agent)) {
// IE
$dl_link = "Save Target As ...";
} elseif (preg_match('/.*?Chrome/i',$agent)) {
// Chrome
$dl_link = "Save link As ...";
} elseif (preg_match('/.*?Safari/i',$agent)) {
// Safari
$dl_link = "Download Linked File As...";
} else {
// default to IE, why not?
$dl_link = "Save Target As ...";
}
return $dl_link;
}
Then echo the function in your markup.
< ?php echo contextual_download_text(); ?>
Published on June 29, 2011
Add Post Thumbnails to RSS Feeds in WordPress
function rss_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<p>' . get_the_post_thumbnail($post->ID) . '</p>' . get_the_content();
}
return $content;
}
add_filter('the_excerpt_rss', 'rss_post_thumbnail');
add_filter('the_content_feed', 'rss_post_thumbnail');
Published on June 14, 2011
Regex Reverse Matching
The fact that regex doesn’t support inverse matching is not entirely true. You can mimic this behavior by using negative look-arounds:
^((?!mystring).)*$
The regex above will match any string, or line without a line break, not containing the (sub) string ‘mystring’. This is not something regex is “good” at (or should do), but still, it is possible.
Thanks to a poster at stackoverflow.com for the solution.
Published on June 14, 2011Adding media upload capabilities to contributor role in wordpress
Here’s the trick:
if ( current_user_can('contributor') && !current_user_can('upload_files') )
add_action('admin_init', 'allow_contributor_uploads');
function allow_contributor_uploads() {
$contributor = get_role('contributor');
$contributor->add_cap('upload_files');
}
Published on June 14, 2011
Listening Habits
I love data. I’m also quite privy to the visualization of data. When I can mix this with my daily music listening habits, the thought just gets me all tingly. Enter the last.fm playground – there’s all sorts of fun to be had. This visualization in particular was of note to me, because according to the data, I should be a gender neutral fluid 24 year old.
Moving Violations
Ouch! Austin bike laws have officially been updated. No more running stop signs I guess.
Published on March 3, 2011PHP Sessions
Now I’m not sure this is due to the short comings of my coding skills or what. But I’ve found it necessary to re-declare session variables before including them in a MySQL INSERT statement.
Here’s the (il)logic:
$_SESSION["mysessionarray"] = arrary();
Push all $_POST variables, or what-have-you, into the array. Then prior to your INSERT statement:
$myvar = $_SESSION["mysessionarray"]["myvar"];
Use your new $myvar in your MySQL INSERT
EDIT: Um, rookie mistake 101. Should’ve just escaped the quotes in the $_SESSION vars. My bad.
Published on February 28, 2011