View generator.js
1 2 3 4 5 6 7 8 9 10
// 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(' ');
}
View rot13.rb
1 2 3 4 5 6 7 8 9 10
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]
View gist:9843631
1 2
// Does not match against already-encoded HTML entities (e.g. &amp;)
/&(?!(?:[a-z0-9]+|#x?[a-z0-9]{1,4});)/i
View gist:8969418
1 2 3 4 5
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.
View gist:8247479
1 2 3 4 5 6 7 8
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('/'));
View gist:7836276
1 2 3 4
// Convert CamelCase to an under_scored_word
function underscore(s){
return s.replace(/(?!^)([A-Z])/g, function(m){ return '_' + m }).toLowerCase();
}
View gist:7714414
1 2 3 4 5 6 7 8 9
<?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);
}
View drupal_var_fix.php
1 2 3 4 5 6 7 8 9 10
#!/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;') {
View gist:6833135
1 2 3 4 5 6 7 8 9 10
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;
View css_URIs.js
1 2 3
$.each(document.styleSheets, function() {
this.href ? console.log(this.href) : $.map(this.cssRules, function(import){ console.log(import.href) })
})
Something went wrong with that request. Please try again.