Skip to content

Instantly share code, notes, and snippets.

View freeformz's full-sized avatar

Edward Muller freeformz

View GitHub Profile
@freeformz
freeformz / piper.rb
Created September 24, 2010 02:48
silly piper
READ_BUF = 1024
HIGH_WATER = 1024
$fin = nil
$fout = nil
def open_fin
if $fin.nil? || ($fin.is_a?(File) && ($fin.eof? || $fin.closed?))
@freeformz
freeformz / collectd-configure-vmware.patch
Created November 24, 2010 01:30
vmware client sdk plugin for collectd. Against collect 4.7.4
--- configure.in
+++ configure.in
@@ -3337,6 +3337,7 @@
dependency_warning="no"
dependency_error="no"
+plugin_vmware="yes"
plugin_ascent="no"
plugin_battery="no"
plugin_bind="no"
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
largestDivisible :: Integer
largestDivisible = head (filter p [100000,99999..])
where p x = x `mod` 3829 == 0
Solved!
Oh duh. It's a function!
p x = x `mod` 3829 == 0
p takes x and performs
@freeformz
freeformz / gist:959014
Created May 6, 2011 14:08
Philippe's 3 Rules of Software Craftsmanship
Rule #1 - "Start with a vision"
Rule #2 - "Throwing more bodies at software projects only makes things worse"
Rule #3 - "There are three vectors that drive software craftsmanship: quality, schedule, and features. The challenge is that you only get to pick two"
@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'