This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quote generator for | |
// http://sextrexcomedy.com/2013/07/23/cowboy-quote-generator/ | |
// Outputs a list of quotes. Choose your favourite and make it an image macro! | |
function generateQuote(){ | |
for (var $rows=jQuery('table tr'), numrows=$rows.length, phrase=[], i=2;i<=4;i++){ | |
phrase.push( $rows.eq( ~~(Math.random() * numrows) ).find('td:nth-child('+i+')').text().trim() ); | |
} | |
return phrase.join(' '); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rot13(word) | |
alphabet = ('a'..'z').to_a | |
word.downcase.split('').map do |letter| | |
index = alphabet.index(letter) | |
if index >= 13 | |
index -= 13 | |
else | |
index += 13 | |
end | |
alphabet[index] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Does not match against already-encoded HTML entities (e.g. &) | |
/&(?!(?:[a-z0-9]+|#x?[a-z0-9]{1,4});)/i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONVENT CONNIVANCE CONFUDDLES CONSTABLES: | |
Considering conspicuous conduct concerning constant congregation confessions, Contra-Conformists confident | |
Conservative congressmen conversion conspiracy continues, constructing contrived convivial consecrations | |
connecting controversial contretemps. Consequently, consistent concentrated conflict convulses Connecticut; | |
Confederates' condos condemned. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = []; | |
for (var i in localStorage){ | |
if (localStorage.propertyIsEnumerable(i) && i.indexOf('dataset_')===0){ | |
a.push( i.split('_')[1] ); | |
} | |
} | |
$('#container').load([location.path, a.join('|')].join('/')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert CamelCase to an under_scored_word | |
function underscore(s){ | |
return s.replace(/(?!^)([A-Z])/g, function(m){ return '_' + m }).toLowerCase(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
static function present($object){ | |
$klass= ucfirst(preg_replace_callback('/_([a-z])/', | |
function($m) { return strtoupper($m[1]);}, | |
$object->type)). 'Presenter'; | |
return new $klass($object); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env drush | |
# Once it prints the faulty variable names, just re-set the values using `drush vset {variable_name} "{value}" | |
$variables = db_query('SELECT name, value FROM {variable}')->fetchAllKeyed(); | |
foreach ($variables as $key => $val) { | |
$v = unserialize($val); | |
if ($v === FALSE && $val !== 'b:0;') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
div { font-family: Helvetica, Arial, sans-serif; width: 50%;} | |
ol li { | |
list-style-type: none; | |
counter-increment: li; | |
margin-bottom: 0.5em; | |
margin-left: 3em; | |
} | |
ol li:before { | |
content: counter(li); | |
position: relative; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.each(document.styleSheets, function() { | |
this.href ? console.log(this.href) : $.map(this.cssRules, function(import){ console.log(import.href) }) | |
}) |
NewerOlder