Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Crittenden mikecrittenden

View GitHub Profile
@mikecrittenden
mikecrittenden / gist:306749
Last active Aug 9, 2016
Auto tab size in Gedit
View gist:306749
if view.get_insert_spaces_instead_of_tabs():
tabsize = view.get_tab_width()
spaces = ""
for i in range(tabsize):
spaces += " "
after = after.replace("\t",spaces)
View gist:461364
function getEbooks(l,s,p,pw) {
// l=loc
// s = subject
// p = prodID (optional)
// pw - use password
url = "ebooks.php?loc=" + l + "&subject=" + s + "&prod=" + p + "&pw=" + pw;
$("#results").empty().html('<img align = "right" src="http://galesupport.com/picts/loading_cengage.gif" alt="loading" />');
$("#results").load(url);
View gist:515777
find ./ -type f -exec sed -i ’s/oldstring/newstring/’ {} \;
View gist:515781
a:link[href^="http://"]:after,
a[href^="http://"]:visited:after,
a:link[href^="https://"]:after,
a[href^="https://"]:visited:after {
content: " (" attr(href) ") ";
font-size: 90%;
}
View gist:515830
<?php
function THEMENAME_preprocess_node(&$vars, $hook) {
$vars['content'] = preg_replace('/<p>(?!<img)/','<p class="first">', $vars['body'], 1);
}
View gist:515841
<?php
/**
* Implementation of hook_translated_menu_link_alter()
*/
function MODULENAME_menu_translated_menu_link_alter(&$item, $map) {
$num_unapproved = db_result(db_query("SELECT count(*) FROM {node} WHERE status = '0' AND type = 'NODETYPE'"));
if ($num_unapproved > 0 && $item['mlid'] == '2101') {
$item['localized_options']['attributes']['class'] = 'attention';
}
}
View gist:515851
jQuery.fn.slowEach = function( interval, callback ) {
var array = this;
if( ! array.length ) return;
var i = 0;
next();
function next() {
if( callback.call( array[i], i, array[i] ) !== false )
if( ++i < array.length )
setTimeout( next, interval );
}
View gist:515852
$('.image').slowEach(5000, function() {
//code here
});
View gist:515858
<div class="post $post.feather{% if post.pinned %} pinned{% endif %}{%if post.aggregate %} ${ post.aggregate | lower }{% endif %}" id="post_$post.id">