Skip to content

Instantly share code, notes, and snippets.

@ejfinneran
ejfinneran / gist:589839
Created September 21, 2010 15:18
A way to get more swap on low tier VMs that don't allow swap paritions.
We couldn’t find that file to show.
@ejfinneran
ejfinneran / gist:635898
Created October 20, 2010 06:34
What is up with JSON encoding on ActiveModel::Errors?
ruby-1.8.7-p302 > hash
=> #<OrderedHash {:email=>["is too short (minimum is 6 characters)", "should look like an email address."]}>
ruby-1.8.7-p302 > u.errors
=> #<OrderedHash {:email=>["is too short (minimum is 6 characters)", "should look like an email address."]}>
ruby-1.8.7-p302 > hash == u.errors
=> true
ruby-1.8.7-p302 > hash.to_json == u.errors.to_json
=> false
ruby-1.8.7-p302 > hash.to_json
=> "{\"email\":[\"is too short (minimum is 6 characters)\",\"should look like an email address.\"]}"
@ejfinneran
ejfinneran / et_via_soap.rb
Created March 11, 2011 18:55
Example Rails code from ET's Website... yuck.
sendClass = SendClassification.new(nil,nil,nil,nil,nil,nil,nil,189,nil,nil,nil,nil,nil,nil,nil,nil)
sendProf = SenderProfile.new(nil,nil,nil,nil,nil,nil,nil,352,nil,nil,nil,nil,'NTO Customer Support','[email protected]',nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil)
delProf = DeliveryProfile.new(nil,nil,nil,nil,nil,nil,nil,306,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil)
email = Email.new(nil,nil,nil,nil,nil,2052608,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil)
sendDefList = SendDefinitionList.new(nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,objID,'CustomObject',nil,nil,nil,nil,nil)
emailSendDef = EmailSendDefinition.new(nil,nil,nil,nil,nil,nil,nil,customerKey,nil,nil,customerKey,desc,nil,nil,nil,sendClass,sendProf,nil,nil,delProf,nil,nil,nil,nil,nil,nil,nil,nil,0,0,sendDefList,email,nil,nil,nil,'Thank You for Contacting NTO Customer Support',nil,1,1,nil,nil,nil,nil,1,nil,nil,nil,'[email protected]'
@ejfinneran
ejfinneran / nova-api.log
Created August 31, 2011 22:22
OpenStack Nova-API Log
AWSAccessKeyId=8c0b75a4-0535-4154-8276-2fbd92bf93b3%3Amyproject&Action=DescribeInstances&Filter.1.Name=instance-id&Filter.1.Value.1=i-0000001e&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2011-08-30T22%3A57%3A37Z&Version=2011-05-15 from (pid=835) _calc_signature_2 /usr/lib/pymodules/python2.6/nova/auth/signer.py:144
2011-08-30 17:57:38,351 DEBUG nova.signer [-] len(b64)=44 from (pid=835) _calc_signature_2 /usr/lib/pymodules/python2.6/nova/auth/signer.py:147
2011-08-30 17:57:38,351 DEBUG nova.signer [-] base64 encoded digest: Y9pubpf1BK7y2873E1hKwcstNU3thFBmTSp8noZd+PQ= from (pid=835) _calc_signature_2 /usr/lib/pymodules/python2.6/nova/auth/signer.py:148
2011-08-30 17:57:38,351 DEBUG nova.auth.manager [-] user.secret: f87a53c2-2961-462b-a62b-ecf00516c4b7 from (pid=835) authenticate /usr/lib/pymodules/python2.6/nova/auth/manager.py:314
2011-08-30 17:57:38,352 DEBUG nova.auth.manager [-] expected_signature: Y9pubpf1BK7y2873E1hKwcstNU3thFBmTSp8noZd+PQ= from (pid=835) authenticate /usr/lib/pymodules/pyt
@ejfinneran
ejfinneran / nova-api.log
Created September 2, 2011 16:40
Nova-API describe key pairs w/ filters
AWSAccessKeyId=8c0b75a4-0535-4154-8276-2fbd92bf93b3%3Amyproject&Action=DescribeKeyPairs&Filter.1.Name=key-name&Filter.1.Value.1=openstack&SignatureMethod=HmacSHA256&SignatureVers
ion=2&Timestamp=2011-09-02T16%3A38%3A42Z&Version=2011-05-15 from (pid=881) _calc_signature_2 /usr/lib/pymodules/python2.6/nova/auth/signer.py:144
2011-09-02 11:38:42,672 DEBUG nova.signer [-] len(b64)=44 from (pid=881) _calc_signature_2 /usr/lib/pymodules/python2.6/nova/auth/signer.py:147
2011-09-02 11:38:42,673 DEBUG nova.signer [-] base64 encoded digest: H+j/YSIHpRrWq37o+zl+PSZZM2BUsiPFqqatcc3fOPw= from (pid=881) _calc_signature_2 /usr/lib/pymodules/python2.6/no
va/auth/signer.py:148
2011-09-02 11:38:42,673 DEBUG nova.auth.manager [-] user.secret: f87a53c2-2961-462b-a62b-ecf00516c4b7 from (pid=881) authenticate /usr/lib/pymodules/python2.6/nova/auth/manager.p
y:314
2011-09-02 11:38:42,673 DEBUG nova.auth.manager [-] expected_signature: H+j/YSIHpRrWq37o+zl+PSZZM2BUsiPFqqatcc3fOPw= from (pid=881) authenticate /usr/lib/pymodules/pytho
@ejfinneran
ejfinneran / Hubot-http.coffee
Created December 14, 2011 07:15
Hubot example script
module.exports = (robot) ->
http = require('http')
server = http.createServer((request, response) ->
params = require('url').parse(request.url, true)
message = params["query"]["message"]
response.writeHead(200, {"Content-Type": "text/plain"})
robot.messageRoom "[email protected]", message
response.end("Message Sent")
)
server.listen(8080, "127.0.0.1")
@ejfinneran
ejfinneran / hubot_via_http
Created January 21, 2012 04:06
Hubot via HTTP
module.exports = (robot) ->
http = require('http')
server = http.createServer((request, response) ->
params = require('url').parse(request.url, true)
message = params["query"]["message"]
response.writeHead(200, {"Content-Type": "text/plain"})
robot.msgRoom "[email protected]", message
response.end("Message Sent")
)
server.listen(1337, "127.0.0.1")
@ejfinneran
ejfinneran / date_wtf.rb
Created February 3, 2012 04:38
Date weirdness
Loading development environment (Rails 3.1.0)
ruby-1.9.2-p290 :001 > Date.today
=> Thu, 02 Feb 2012
ruby-1.9.2-p290 :002 > Date.tomorrow
=> Sat, 04 Feb 2012
ruby-1.9.2-p290 :003 > Time.zone = "America/Chicago"
=> "America/Chicago"
ruby-1.9.2-p290 :004 > Date.today
=> Thu, 02 Feb 2012
ruby-1.9.2-p290 :005 > Date.tomorrow
@ejfinneran
ejfinneran / wat.md
Created November 26, 2012 03:03
Ruby Const WAT

MRI

1.9.3-p194 :011 > [1, 2, 3].each {|X| puts X }
SyntaxError: (irb):11: formal argument cannot be a constant
[1, 2, 3].each {|X| puts X }
                  ^
	from /Users/ej/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
@ejfinneran
ejfinneran / mysql_wat.sql
Created February 5, 2013 21:39
MySQL WAT
mysql> create database unique_test;
Query OK, 1 row affected (0.00 sec)
mysql> use unique_test;
Database changed
mysql> create table table_with_unique_index (name TEXT, foo INT, bar INT);
Query OK, 0 rows affected (0.02 sec)