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 / git-find-original.sh
Last active December 30, 2015 18:29
Using git bisect to find the original commit that a piece of code/text entered the repo. Need this because many times you want to trace back when it was added, but when running a git show/blame you end up finding commits that just move that chuck around in the file/to different files etc.
# USAGE:
# reason for this is because sometimes you want to know when the originating code/comment/whatever was brought into the repo
# but you end up following a trace of lots of commits that just moved around the original chunk of code.
# this uses git bisect to trace back to the original commit that has this text in the repo.
# depends on ack, but you could easily change this to use `grep -r`
#
# $ git-find-original "some search string that you want to find the original commit that had this exact text"
match_arg="$@"
@shaiguitar
shaiguitar / manualcharencodings.rb
Last active December 28, 2015 09:18
manual char encodings
class StringHelper
def char_codes_for(str)
new_str = ""
str.each_char { |c| new_str << "&##{c.ord};" }
new_str
end
end
@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:1032229
Created June 17, 2011 20:20
check processes with kill -0
usage()
{
echo "./$0 [--verbose]"
}
VERBOSE=0
if [ "$1" == "--verbose" ]; then
VERBOSE=1
fi
@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