Skip to content

Instantly share code, notes, and snippets.

View rboyd's full-sized avatar

Robert Boyd rboyd

  • Bentonville, AR
View GitHub Profile
`ls`.split("\n").each { |file|
puts file if file.include? 'gif'
amt = /(\d+).*\.gif/.match(file)[1]
`mv #{amt}top.gif chip#{amt}.gif`
}
-module(date_util).
-compile(export_all).
epoch() ->
now_to_seconds(now())
.
epoch_hires() ->
now_to_seconds_hires(now())
.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
<mx:Canvas id="cnv" />
<mx:Script>
<![CDATA[
[Embed(source="../assets/spritesheet.png")]
private var Sheet:Class;
private static const FRAME_WIDTH:uint = 65;
v1 -- squares 1 thru 10
===
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init(event)">
<mx:Canvas width="800" height="600">
<mx:Panel>
# Merb SessionCookie unmarshalling with validation against secret key. Useful for 3rd service
# (like socket server) to map cookie -> user_id. Pretty much all of this jacked from Merb
# source and distilled into the same place.
require 'base64' # to convert Marshal.dump to ASCII
require 'openssl' # to generate the HMAC message digest
# Cookies can typically store 4096 bytes.
MAX = 4096
@rboyd
rboyd / ec2-us-east-iptables-allow.txt
Created October 22, 2010 13:16
iptables rules for amazon ec2 us east region
# iptables allow rules for ec2 us east (http://developer.amazonwebservices.com/connect/ann.jspa?annID=795)
-A INPUT -s 216.182.224.0/20 -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
-A INPUT -s 72.44.32.0/19 -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
-A INPUT -s 67.202.0.0/18 -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
-A INPUT -s 75.101.128.0/17 -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
-A INPUT -s 174.129.0.0/16 -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
-A INPUT -s 204.236.192.0/18 -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
-A INPUT -s 184.73.0.0/16 -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
-A INPUT -s 184.72.128.0/17 -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
Chipmunk basic for OS X can be downloaded here: http://www.nicholson.com/rhn/basic/#3
The algorithm for binary conversion is a simple one, as described here: http://trunix.org/programlama/cpp/fred/notes/cpp/misc/decimal2binary.html
10 INPUT num
20 WHILE num > 0
30 m = num mod 2
40 out$ = str$(m) + out$
50 num = int(num/2)
60 WEND
@rboyd
rboyd / fader
Created January 24, 2011 03:16
#define LED 9
int i = 0;
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
for (i = 0; i < 255; i++) {
analogWrite(LED, i);
@rboyd
rboyd / conv_gemfile.rb
Created February 9, 2011 05:20
converts Gemfile gems to chef recipe format
#!/usr/bin/ruby
gems_list = Array.new
ARGF.each do |line|
md = /.*\"([^\"]+)\".*(\"[^\"]+\")/.match(line)
gem_name = md.captures[0]
version = md.captures[1]
puts "gem_package \"#{gem_name}\" do\n version #{version}\nend\n\n"
end
@rboyd
rboyd / gist:1010962
Created June 6, 2011 19:57
bare minimum example of shell_wrapper.sh issue
ubuntu@domU-12-31-39-0F-D4-BF:~$ export set ANYVAR='foo
> bar'
ubuntu@domU-12-31-39-0F-D4-BF:~$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'rvm'
=> true
irb(main):003:0> RVM.list_known_strings
ArgumentError: syntax error on line 25, col 0: `bar'
from /usr/lib/ruby/1.8/yaml.rb:133:in `load'