Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
💉💉💉😷

Edward Muller freeformz

💭
💉💉💉😷
View GitHub Profile
View piper.rb
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 Nov 24, 2010
vmware client sdk plugin for collectd. Against collect 4.7.4
View collectd-configure-vmware.patch
--- 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"
View redis_pubsub_demo.rb
# 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
View gist:899221
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
Philippe's 3 Rules of Software Craftsmanship
View gist:959014
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
Fog ECloud Sample Usage
View gist:959520
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 Oct 17, 2011
merge defaults, preserving existing entries .. Is there a better way?
View gist:1293428
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
View gist:1299662
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 Nov 6, 2011
Arduino 101-02 Motor Control
View gist:1343483
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);
View Example
> 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'