Skip to content

Instantly share code, notes, and snippets.

View shaiguitar's full-sized avatar
💭
We can pickle that

Shai Rosenfeld shaiguitar

💭
We can pickle that
View GitHub Profile
@shaiguitar
shaiguitar / pr.md
Created August 29, 2013 17:51 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@shaiguitar
shaiguitar / ninja.rb
Created February 13, 2013 19:13
://sphotos-b.xx.fbcdn.net/hphotos-snc6/377635_345841315524300_1034340001_n.jpg
# inspired by https://sphotos-b.xx.fbcdn.net/hphotos-snc6/377635_345841315524300_1034340001_n.jpg
class NinjaName
class << self
MAPPING = {
"a" => "ka" ,
"b" => "zu" ,
"c" => "mi" ,
"d" => "te" ,
"e" => "ku" ,
@shaiguitar
shaiguitar / Readme.md
Created November 27, 2012 19:11
RubyApisAndClientsTalk

Testing HTTP APIs with Ruby

Good integration tests are hard. There are many approaches for testing server and client libraries all with various tradeoffs and problems that come up. Some are obvious, some are a little more tricky. I'll run through some approaches I've come across developing server APIs along with their corresponding clients, while developing these in a highly distributed systems setup at Engine Yard.

Shai Rosenfeld

Shai is always excited when there is something new to learn, and hence has seemed to have found his fit doing technology.

He started out playing with Ruby and Rails in 2006. After supporting and helping scale some of the largest Ruby production systems, he moved on to development of one of the leading Platform as a Services.

.encoding = "UTF-8"
config.version = "8"
virtualHW.version = "8"
scsi0.present = "TRUE"
scsi0.virtualDev = "lsisas1068"
memsize = "1024"
mem.hotadd = "TRUE"
scsi0:0.present = "TRUE"
scsi0:0.fileName = "Windows 7 x64.vmdk"
ide1:0.present = "TRUE"
@shaiguitar
shaiguitar / gist:3014696
Created June 28, 2012 23:26
realweb spec
1.9.2 realweb [silence_stdout]$ b rspec spec/
The Gemfile's dependencies are satisfied
...>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 127.0.0.1:8848, CTRL+C to stop
.>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 127.0.0.1:9669, CTRL+C to stop
.localhost - - [28/Jun/2012:16:25:37 PDT] "GET / HTTP/1.1" 500 338
- -> /
## GOOD FOR /VERSIONS
## JSON, AND XML
shai@comp ~ » curl https://services.enterprisecloud.terremark.com/cloudapi/ecloud/versions/ -H 'x-tmrk-version: 2011-10-01' -H 'x-tmrk-date: Mon, 20 Feb 2012 23:02:22 GMT' -H 'Authorization: Basic bar' -H 'Accept: application/json'
[{"Version":"2011-07-01","Deprecated":false},{"Version":"2011-10-01","Deprecated":false}]%
shai@comp ~ » curl https://services.enterprisecloud.terremark.com/cloudapi/ecloud/versions/ -H 'x-tmrk-version: 2011-10-01' -H 'x-tmrk-date: Mon, 20 Feb 2012 23:02:22 GMT' -H 'Authorization: Basic bar' -H 'Accept: application/xml' | tidy -mi -xml
<SupportedVersions xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
@shaiguitar
shaiguitar / gist:943915
Created April 27, 2011 08:23
strace loop c
root@Ubuntu-1004-lucid-32-minimal ~ # cat c.c && make c && strace -- ./c
int main() {
for (;;) {
}
return 0;
}
make: `c' is up to date.
execve("./c", ["./c"], [/* 22 vars */]) = 0
class MigrateMailAppRulesToGmailFilters
require 'pp'
# TODO HERE IS WHERE YOU REQUIRE plist lib.
# There's a good chance you can just "gem install plist"
# But I didn't get there, so I'm just showing you what I hacked up.
# Feel free to gem install and require of course.
Dir.chdir("/Users/shair/work/filters/plist/lib") # this is to require plist below.
require 'plist'
MAIL_API_KEYWORDS = %w(MarkRead CopyToMailboxURL)
# USAGE: Hash.from_xml:(YOUR_XML_STRING)
require 'nokogiri'
# modified from http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash/1231297#1231297
class Hash
class << self
def from_xml(xml_io)
begin
result = Nokogiri::XML(xml_io)
return { result.root.name.to_sym => xml_node_to_hash(result.root)}
## Running on 184.73.217.183 ( app_master )
[WARN] Process 'mongrel_adoptadogustine_5000' Execution failed - restart pending
[WARN] Found 1 monit restarts since (now May 16 03:44:52) at a rate of .266 restarts/hour. Latest was 3.7 hours ago.
## Running on ec2-174-129-66-49.compute-1.amazonaws.com ( db_master )
[WARN] 03:45:04 up 16 days, 14:13, 0 users, load average: 3.48, 3.46, 3.33
[WARN] Found 1 monit restarts since (now May 16 03:45:00) at a rate of .266 restarts/hour. Latest was 3.7 hours ago.
## Running on ec2-184-73-100-142.compute-1.amazonaws.com ( util )