Skip to content

Instantly share code, notes, and snippets.

View msonnabaum's full-sized avatar

Mark Sonnabaum msonnabaum

  • Lithic
  • San Diego, CA
View GitHub Profile
{
"name": "webserver",
"default_attributes": {
"apache2": {
"listen_ports": [
"8080",
"443"
]
}
},
#!/usr/bin/env ruby
require 'rubygems'
require 'xmlsimple'
require 'flotr'
log = XmlSimple.xml_in('blah.log')
f = Flotr::Data.new(:label => "Total Response", :color => "red")
#!/usr/bin/env ruby
require 'rubygems'
require 'fastercsv'
require 'json'
class Cvs2json
attr_reader :csv
def initialize(filename)
@filename = filename
// Time interval, this executes one piece of code from time to time
// Download Metro lybrary and instructions:
// http://www.arduino.cc/playground/Code/Metro
#include <Metro.h>
int duration = 3500; // duration of the interval in miliseconds
Metro intervaller = Metro (duration);
// servos minimum and maximum position
#define MIN_POS 2700 // the minuimum pulse width for your servos
#define MAX_POS 5000 // maximum pulse width for your servos
<?php
$result = db_query('SELECT filename, name FROM {system}');
while ($mod = db_fetch_array($result)) {
exec('find . -name ' . basename($mod['filename']), $modpath_arr);
if (count($modpath_arr) == 1) {
$modpath = ltrim($modpath_arr[0], './');
$dbpath = $mod['filename'];
if ($dbpath != $modpath) {
#!/bin/bash
DBHOST='localhost'
DBUSER='root'
SITENAME="${1}"
DBNAME="${SITENAME}"
stty -echo
read -p "MySQL Password: " DBPASS;
stty echo
<?php
function drupal_commons_add_role($name) {
module_load_include('inc', 'user', 'user.admin');
$form_state = array();
$form_state['values']['name'] = $name;
$form_state['values']['op'] = "Add role";
drupal_execute('user_admin_role', $form_state);
}
[difftool]
prompt = false
[diff]
tool = Kaleidoscope
[core]
; Don't trust file modes
filemode = false
[color]
ui = auto
status = auto
@msonnabaum
msonnabaum / strip_inline_styles.php
Created December 14, 2010 21:46
Strips out inline styles like '<span style="font-family:arial;font-size:13px">'. Arguments work similarly to strip_tags().
<?php
function strip_inline_styles($string, $allowed_styles = array()) {
$pattern = '/style="([^"\']+)"/';
$parsed = preg_replace_callback($pattern, function($match = NULL) use($allowed_styles) {
// Get style attribute values
$styles = $match[1];
// Parse each sytle out
$pattern2 = "/(?:([\w-]+?):([\w-]+);?)/";
$parsed_styles = preg_replace_callback($pattern2, function($match2 = NULL) use($allowed_styles, $styles) {
@msonnabaum
msonnabaum / drush-test.sh
Created January 13, 2011 03:43
Test using roundup for drush cli testing.
#!/usr/bin/env roundup
describe drush
before() {
__DIR__="$PWD"
rm -rf .sandbox
mkdir -p .sandbox
cd .sandbox
}