Skip to content

Instantly share code, notes, and snippets.

View freshtonic's full-sized avatar
🎯

James Sadler freshtonic

🎯
  • Sydney, Australia
View GitHub Profile
@freshtonic
freshtonic / gist:1266497
Created October 6, 2011 04:04
Nokogiri clobbers LibXML's error handlers
describe "Nokogiri & LibXML interaction" do
it "LibXML's error handler should not be clobbered by Nokogiri::XSLT(...)" do
malformed_xml = '<?xml version="1.0" encoding="utf-8"?>
<some_tag>
</some_tag_with_typo>'
xslt = '<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="product">
@freshtonic
freshtonic / gist:1326669
Created October 31, 2011 01:00
Vi on the command line
In your ~/.inputrc (make one if you don't have one):
set editing-mode vi
In your ~/.bashrc (or whatever)
set -o vi
Launch a new command prompt, you should have vi keybindings. If you get sick of it, set -o emacs will fix it.
@freshtonic
freshtonic / gist:1390291
Created November 24, 2011 00:00
Run Postgres Specs in Ramdisk
  • This creates a 560mb ramdisk. Adjust the size accordingly. I think the number at the end of the command is the number of disk blocks. They are 2kb in size for me.
  • Restarting postgres is not necessary; you can create the ramdisk and tablespace while postgres is running.
  • You will lose all data in the ramdisk tablespace when you shut your machine down

  $ diskutil erasevolume HFS+ "postgres_ramdisk" `hdiutil attach -nomount ram://1165430`
  Started erase on disk1
  Unmounting disk
  Erasing
 Initialized /dev/rdisk1 as a 569 MB HFS Plus volume
@freshtonic
freshtonic / gist:1623926
Created January 17, 2012 01:03
Git update hook to disallow fast-forwards for master and release branches
#!/usr/bin/env ruby
$refname = ARGV[0]
$oldrev = ARGV[1]
$newrev = ARGV[2]
$user = ENV['USER']
puts "Enforcing Policies... \n(#{$refname}) (#{$oldrev[0,6]}) (#{$newrev[0,6]})"
NON_FASTFORWARD_BLACKLIST = [/\brelease\b/, /\bmaster\b/]
@freshtonic
freshtonic / gist:1656210
Created January 22, 2012 08:01
Weird JS problem
(function() {
var fixedAssetColumns, totalsRowTemplate;
fixedAssetColumns = [
{
name: 'description'
}, {
name: 'date'
}
];
@freshtonic
freshtonic / gist:1999083
Created March 8, 2012 06:07
Git hook to disallow non-fastforward updates (also disallows merges into feature branches in order to keep them cleanly rebaseable)
#!/usr/bin/env ruby
# This update hook enforces the following policies
# 1) release and master branches are fast-forward only
# 2) feature branches cannot contain merges
$refname = ARGV[0]
$oldrev = ARGV[1]
$newrev = ARGV[2]
@freshtonic
freshtonic / mountains.html
Created May 27, 2012 14:56
Fractal mountains vista
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript' src='/javascript/jquery-1.7.2-min.js'></script>
<script type='text/javascript'>
(function(){
var mountains = null;
var canvas = null;
var context = null;
@freshtonic
freshtonic / gist:2843057
Created May 31, 2012 12:26
no one was ready for it yet
For example, I was co-founder of a startup called Neowurks (yeah shit name)
about 10 years ago.
It was an app for the telco industry, in the area of rates exchange and route
provisioning.
At least once per week, all the telcos would exchange their rates for
terminating calls at major cities around the world. Pricing was per million
minutes, at 4 or 5 levels of quality of service and for mobile versus landline.
@freshtonic
freshtonic / gist:3494515
Created August 28, 2012 02:53
AngularJS stuff I'm just not getting my head around
doctype 5
html(lang="en", ng-app="blaze-control-panel")
head
title 'Blaze Control Panel'
meta(name="viewport", content="width=device-width, initial-scale=1.0")
link(href="css/bootstrap.css", rel="stylesheet", type="text/css")
link(href="css/bootstrap-responsive.css", rel="stylesheet", type="text/css")
link(href="css/app.css", rel="stylesheet", type="text/css")
script(src='js/lib/jquery-1.8.0.min.js')
script(src='js/lib/underscore-1.3.3.min.js')
@freshtonic
freshtonic / gist:3607468
Created September 3, 2012 07:01
effingPuts
global.effingPuts = ( ->
fs = require 'fs'
sys = require 'sys'
(msg) ->
if typeof msg is 'String'
fs.writeSync 1, msg
else
fs.writeSync 1, sys.inspect(msg)
fs.fsyncSync 1
)()