Skip to content

Instantly share code, notes, and snippets.

View ngmaloney's full-sized avatar

Nick Maloney ngmaloney

View GitHub Profile
<?php
//Removing teaser view from a Drupal Node Preview
/**
* Overrided default preview output by removing teaser view
**/
function mytheme_preview($node) {
$output = '<div class="preview">';
$output .= node_view($node, 0, FALSE, 0);
@ngmaloney
ngmaloney / drupal_update.sh
Created March 18, 2010 16:03
Drupal Drush Update Script
#!/bin/bash
DRUSH="$(which drush)"
BASEDIR="/var/www/vhosts/mysite.com/httpdocs"
cd $BASEDIR
#Iterate through sites and put in offline mode
ls $BASEDIR/sites |while read line
do
if [[ "$line" != "all" && "$line" != "default" && "$line" != "CVS" ]]
then
Index: js/jquery.utils.lite.js
===================================================================
--- js/jquery.utils.lite.js (revision 3)
+++ js/jquery.utils.lite.js (working copy)
@@ -1125,12 +1125,12 @@
*/
$.widget('ui.keynav', {
- _init: function(){
+ _create: function(){
@ngmaloney
ngmaloney / gist:674330
Created November 12, 2010 16:47
Hide pesky modal popups on cctimes
javascript:;jQuery('#colorbox, #cboxOverlay').remove();jQuery('.articleGraf').show();
@ngmaloney
ngmaloney / gist:733586
Created December 8, 2010 17:23
top comments by uid
select c.uid, c.cid, c.created
from (
select uid, max(created) as maxcreated
from comment group by uid
) as x inner join comment as c on c.uid = x.uid and c.created = x.maxcreated
order by maxcreated desc
@ngmaloney
ngmaloney / gist:744545
Created December 17, 2010 05:52
Mongodb Max Length MapReduce
reduce = function(key,vals) {
return vals.sort(function(a,b){return b - a})[0];
}
map = function() {
var map_send = function(k,v) {
emit(k,v.toString().length);
}
@ngmaloney
ngmaloney / gist:981766
Created May 19, 2011 21:17
my.drush.inc
<?php
/**
* @file My Drush Commands
*/
/**
* Implementation of hook_drush_help()
*/
function my_drush_help($section) {
switch ($section) {
@ngmaloney
ngmaloney / gist:1018167
Created June 10, 2011 03:01
Solution to Puzzlenode.com #4 Robots vs Lasers
class RobotGuidanceSystem
attr_accessor :schematics
def initialize(input_file)
self.schematics = []
f = File.open(input_file) if File.exists? input_file
parse_schematics f.read if f
end
def run
@ngmaloney
ngmaloney / get_meta_description.js
Created June 27, 2011 21:07
A Javascript function used to extract meta description from an HTML document.
/**
* Returns document meta description
*/
getMetaDescription = function() {
var metas = document.getElementsByTagName('meta');
for(var i in metas) {
if (typeof(metas[i].name) != 'undefined' && metas[i].name.toLowerCase() == "description") {
return encodeURIComponent(metas[i].content);
}
}
@ngmaloney
ngmaloney / csvdiff.rb
Created July 22, 2011 17:58
Quick and Dirty delta between 2 csv files
#!/usr/bin/env ruby
#
# A 30 second hack job to compare two CSV files
#
file1 = ARGV[0] ? ARGV[0] : false
file2 = ARGV[1] ? ARGV[1] : false
file1_set = []
file2_set = []
delta = []