You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';This is quite common and very helpful. Another option is to do:
name || (name = 'joe');| <?php | |
| /***** | |
| All new versions will be posted at | |
| https://github.com/rmccue/Rotor_WPPlugin | |
| Please use that repository instead of this Gist. | |
| ******/ |
| /** | |
| * Annoying.js - How to be an asshole to your users | |
| * | |
| * DO NOT EVER, EVER USE THIS. | |
| * | |
| * Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com) | |
| * Visit https://gist.github.com/767982 for more information and changelogs. | |
| * Visit http://kilianvalkhof.com/2011/javascript/annoying-js-how-to-be-an-asshole/ for the introduction and weblog | |
| * Check out https://gist.github.com/942745 if you want to annoy developer instead of visitors | |
| * |
| /* | |
| For more detailed instructions on how to use this script, sign up with your email here: | |
| http://adamloving.com/internet-programming/how-toexport-facebook-page-fans | |
| DISCLOSURE: This javascript runs in your browser pretending to be you | |
| looking through your page fans. Facebook should have no problem with this, | |
| but who knows if they will think it is strange to see you looking through | |
| all your fans so quickly (the script waits 3s before requesting each page). | |
| I've had no problem running this so far for 1000s of page fans, but I |
You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';This is quite common and very helpful. Another option is to do:
name || (name = 'joe');| <?php | |
| # Instead of | |
| $name = 'Jeff'; | |
| switch ($name) { | |
| case 'Jeff': | |
| echo "I'm Jeff"; | |
| break; | |
| case 'Joe': |
| // Fun little quiz | |
| Assuming this string: "January 5th, 2012" | |
| In the shortest amount of code possible, place: | |
| - 'January' within a $month variable | |
| - '5th' within a $day variable | |
| - '2012' within a $year variable. |
| //I'm using a preprocessor, called Stylus | |
| full_width = 80 | |
| columns = 12 | |
| gutter = 1 | |
| .container | |
| width unit(full_width, '%') | |
| margin auto | |
| overflow hidden |
This gist assumes:
| <? | |
| //connect to your database | |
| //query comments for this page of this article | |
| $inf = "SELECT * FROM `comments` WHERE page = '".stripslashes($_SERVER['REQUEST_URI'])."' ORDER BY time ASC"; | |
| $info = mysql_query($inf); | |
| if(!$info) die(mysql_error()); | |
| $info_rows = mysql_num_rows($info); |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <script type="text/javascript" src="d3.js"></script> | |
| <script type="text/javascript"> | |
| function draw(data){ | |
| "use strict"; | |
| //badass visualization code gone |