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 / 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: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 / gist:1656210
Created January 22, 2012 08:01
Weird JS problem
(function() {
var fixedAssetColumns, totalsRowTemplate;
fixedAssetColumns = [
{
name: 'description'
}, {
name: 'date'
}
];
@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: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: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: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:1180160
Created August 30, 2011 04:06
rubygems bullshit
gem list | grep rake
rake (0.9.2, 0.8.7)
jamessadler@elnido~ ruby-1.8.7-p352@wf (WSF-2495$+90)
⚡ gem uninstall rake --version=0.9.2
You have requested to uninstall the gem:
rake-0.9.2
uuidtools-2.1.1 depends on [rake (>= 0.8.3)]
rack-1.3.2 depends on [rake (>= 0)]
launchy-0.3.7 depends on [rake (>= 0.8.1)]
Hi all,
This Saturday 22nd Jan from 1pm until whenever you are invited to join me for some informal drinks and/or food at The Welcome Hotel, 91 Evans Street, Balmain.
I have reserved a couple of tables in the beer garden at the back. It would be great to catch up with everyone before Kel and I embark on our big trip - we're going to be out of the country for about a year... exciting!
Obligatory Google Maps link:
http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=the+welcome+hotel,+balmain&aq=&sll=37.0625,-95.677068&sspn=45.553578,93.076172&ie=UTF8&hq=the+welcome+hotel,+balmain&hnear=&radius=15000&ll=-33.86279,151.173506&spn=0.046897,0.090895&z=14
# See what a 'refactored' page looked like before you fucked it up
In your Rails/Sinatra/Whatever app when running in your development environment, expose a 'commit' parameter.
If that parameter is present, have your app serve the view as it was at that commit. E.G. http://localhost:3000/session/new&_commit=HEAD^.
You'll need to intercept whatever you need to in order to determine the file to render (dependent on framework), but ultimately you just need a call to Git like this to make it work:
`git show #{params['_commit']}:#{path_to_view} > #{tmp_file}`