Skip to content

Instantly share code, notes, and snippets.

@robballou
robballou / graph.js
Created December 20, 2013 16:22
Step 1: run our D3 script with node!
require('d3');
var xmldom = require('xmldom');
var dataset = {
apples: [53245, 28479, 19697, 24037, 40245],
};
var width = 460,
height = 300,
radius = Math.min(width, height) / 2;
@robballou
robballou / settings.php
Last active December 29, 2015 00:29
A basic Drupal dev site settings file.
<?php
/**
* @file
* Settings.
*/
$databases = array(
'default' => array(
'default' => array(
'database' => '',
@robballou
robballou / sha.py
Last active December 28, 2015 10:39
Output hash for a string
#!/usr/bin/env python
"""
Output hash for a string
If not string is specified, then prompt for one (good for passwords). By default
the script will use SHA1, but you can specify any of the following:
--all (or -a)
--base64 (or -b)
#!/usr/bin/env python
import argparse
import sh
import re
import os
def verbose(message, options={}):
"""Display a message if we are using verbose mode"""
if 'verbose' not in options or not options.verbose:
@robballou
robballou / gist:5871098
Last active December 19, 2015 00:49
Use dpq() in Drupal to write the SQL query to a file.
<?php
$query = db_select('node', 'n');
$string = dpq($query, TRUE);
dd($string);
@robballou
robballou / gist:5302105
Created April 3, 2013 15:15
Work-in-progress of a sublime plugin to fold just functions.
import sublime, sublime_plugin
import re
class FoldFunctionsCommand(sublime_plugin.TextCommand):
def run(self, edit):
# find things marked as a meta.function
functions = self.view.find_by_selector('meta.function.php')
print "FoldFunctions: functions found: %d" % len(functions)
# loop through those functions and figure out what region that they
# take up.
#!/bin/bash
# create an empty shell module
if [[ $# -ne 1 ]]; then
echo 'Usage: drupal_make_module.sh [module_name]'
exit 1
fi
if [[ ! -d sites/all/modules ]]; then
#!/usr/bin/env python
import argparse
import sh
import re
import os
def verbose(message, options={}):
"""Display a message if we are using verbose mode"""
if 'verbose' not in options or not options.verbose:
@robballou
robballou / closures.js
Created December 17, 2012 15:39
Code from my JavaScript Best Practices from AtenCamp 2012
// closures
(function($, Drupal, drupalSettings) {
var snow_base = 10;
Drupal.behaviors.snowman = {
attach: function() {
// can access $, Drupal, drupalSettings
}
@robballou
robballou / gist:4171749
Created November 29, 2012 20:37
Tag a release and push
git tag release-`date +"%Y%m%d"` && git push origin release-`date +"%Y%m%d"`