Skip to content

Instantly share code, notes, and snippets.

View freeformz's full-sized avatar

Edward Muller freeformz

View GitHub Profile
@freeformz
freeformz / gist:959520
Created May 6, 2011 18:40
Fog ECloud Sample Usage
gem install fog
Successfully installed fog-0.7.2
1 gem installed
cat ~/.fog
:default:
:ecloud_username: <ecloud username>
:ecloud_password: <ecloud password>
:ecloud_versions_uri: https://services.enterprisecloud.terremark.com/api/versions
@freeformz
freeformz / gist:1293428
Created October 17, 2011 18:46
merge defaults, preserving existing entries .. Is there a better way?
class Hash
def with_defaults(defaults={})
self.merge(defaults) { |k,o,n| o }
end
def with_defaults!(defaults={})
self.merge!(defaults) { |k,o,n| o }
end
end
def work
@count += 1
GC.start
before = Hash.new(0)
ObjectSpace.each_object { |o| before[o.class] += 1 }
super
GC.start
after = Hash.new(0)
ObjectSpace.each_object { |o| after[o.class] += 1 }
p "count: #{@count}"
@freeformz
freeformz / gist:1343483
Created November 6, 2011 21:03
Arduino 101-02 Motor Control
int motorPin = 9;
int potPin = 0;
int lastValue = 0;
int motorSpeed = 0;
int delayTime = 250;
void setup() {
Serial.begin(9600);
pinMode(motorPin, OUTPUT);
analogWrite(motorPin, motorSpeed);
> io dsl1.io
list(Ed Muller)
list(555-555-1212)
^^ works
via the repl \/ it doesn't. I get...
pn := doString("{ \"Ed Muller\": \"555-555-1212\" }")
Exception: Map does not respond to 'call'
@freeformz
freeformz / README.txt
Created February 1, 2012 20:14
FizzBuzz
Looking for creative FizzBuzziness.....
One per file, all languages accepted.
@freeformz
freeformz / exceptional.io.js
Created February 20, 2012 19:58
DotJS s/h2/pre/
function preify() {
if ( $('#tmplPaging').css('display') == 'none' ) {
setTimeout( preify, 1000);
} else {
$('#offline_occurrences li h2')
.replaceWith(function() { return '<pre>' + $(this).text() + '</pre>' });
}
}
$(document).ready( preify );
@freeformz
freeformz / gist:2866845
Created June 4, 2012 07:06
PL/PGSQL fizzbuzz
CREATE OR REPLACE FUNCTION fizzbuzz()
RETURNS setof text as $$
BEGIN
FOR i IN 1 .. 100 LOOP
IF MOD(i, 15) = 0 THEN
return next 'FizzBuzz';
ELSIF MOD(i, 5) = 0 THEN
return next 'Buzz';
@freeformz
freeformz / gist:3107723
Created July 13, 2012 21:44
My GoTour Exercise #45 (http://tour.golang.org/#45) solution
package main
import (
"strings"
"code.google.com/p/go-tour/wc"
)
// Maybe strings.Fields is cheating?
func WordCount(s string) map[string]int {
@freeformz
freeformz / gist:3108052
Created July 13, 2012 22:50
My GoTour Exercise #46 (http://tour.golang.org/#46) solution
package main
import (
"code.google.com/p/go-tour/pic"
)
func Pic(dx, dy int) [][]uint8 {
s := make([][]uint8, dy)
for y := range s {
s[y] = make([]uint8, dx)