Skip to content

Instantly share code, notes, and snippets.

View tibbon's full-sized avatar

David Fisher tibbon

View GitHub Profile
diff --git a/src/yajl_parser.c b/src/yajl_parser.c
index 398873c..96add32 100644
--- a/src/yajl_parser.c
+++ b/src/yajl_parser.c
@@ -226,11 +226,11 @@ yajl_do_parse(yajl_handle hand, unsigned int * offset,
_CC_CHK(hand->callbacks->yajl_number(
hand->ctx,(const char *) buf, bufLen));
} else if (hand->callbacks->yajl_integer) {
- long int i = 0;
+ unsigned long i = 0;
@tibbon
tibbon / gist:1363126
Created November 14, 2011 02:52
Fixing Skype Links
@skype_text = 'The <a href="http://www.imvox.com">bar</a> of <a href="http://foo.bar">cat</a>'
@skype_text.scan(/\S+">(\S+)<\/a>/).each do |link|
linktext = link[0]
@skype_text.gsub!(/<a href=\"\S+#{linktext}<\/a>/, linktext)
end
p @skype_text
@tibbon
tibbon / gist:1375104
Created November 18, 2011 00:32
Debugging file upload
post '/file_upload' do
@skype_name = params[:user]
if params[:action] == "FILE-UPLOAD"
unless params[:name].match(/\.jpg|png|jpeg/).nil?
current_user = User[:skype_name => @skype_name, :current_account => "1"]
client = current_user.authorize_to_twitter
datafile = Tempfile.new(params[:data])
client.update_with_media("File upload from Skype: ", datafile)
return "text: File posted."
datafile.unlink
@tibbon
tibbon / gist:2393556
Created April 15, 2012 15:57
Helping Dave S get started on Rails 3.x with Heroku
# This creates your rails site in the directory called 'davesite'. You can replace 'davesite' with anything that starts with a letter.
rails new davesite
#Change to the davesite directory.
cd davesite
#Logs you onto Heroku. You only really need to do this once unless you have multiple accounts
heroku login
@tibbon
tibbon / gist:2430478
Created April 20, 2012 17:30
Basic Blog Post HTML5 Layout
<article>
<header>
<hgroup>
<h1>Name of my post</h1>
<h2>subheading</h2>
</hgroup>
<p>By <author><a href="/bio/David_Fisher" rel="author">David Fisher</a></author></p>
<p><time>June 23, 2012</time></p>
</header>
<p>
@tibbon
tibbon / gist:2569089
Created May 1, 2012 15:56
Git Repo Statistics commands
git log --shortstat | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'
git log --shortstat --author "David Fisher" | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'
git log --pretty=format:%an | awk '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }'| sort -r
git shortlog -sn --no-merges
git log --graph --full-history --all --color \
--pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"
@tibbon
tibbon / Gemfile
Created September 13, 2012 15:03
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@tibbon
tibbon / gist:4172304
Created November 29, 2012 22:23
Twitter Gem attempted Test, which is failing
describe "#friends" do
context "with a screen_name passed" do
before do
stub_get("/1.1/friends/list.json").with(:query => {:cursor => "-1", :screen_name => "sferik"}).to_return(:body => fixture("friends_list.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "requests the correct resource" do
@client.friends("sferik")
expect(a_get("/1.1/friends/list.json").with(:query => {:cursor => "-1", :screen_name => "sferik"})).to have_been_made
end
@tibbon
tibbon / gist:4172305
Created November 29, 2012 22:23
Twitter Test Failure results
Failures:
1) Twitter::API::FriendsAndFollowers#friends with a screen_name passed requests the correct resource
Failure/Error: @client.friends("sferik")
WebMock::NetConnectNotAllowedError:
Real HTTP connections are disabled. Unregistered request: GET https://api.twitter.com/1.1/friends/list.json?screen_name=sferik with headers {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'OAuth oauth_nonce="3d48576db86a5390bdc1deaec65c4a13", oauth_signature="h5gsi6Xj8li8Jqn7VzivG399rQc%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1354227722", oauth_version="1.0"', 'User-Agent'=>'Twitter Ruby Gem 4.3.0'}
You can stub this request with the following snippet:
stub_request(:get, "https://api.twitter.com/1.1/friends/list.json?screen_name=sferik").
@tibbon
tibbon / gist:4172664
Created November 29, 2012 23:34
Non-working Twitter Method
def friends(*args)
options = extract_options!(args)
merge_default_cursor!(options)
users_from_response(:get, "/1.1/friends/list.json", options)
end
1) Twitter::API::FriendsAndFollowers#friends with a screen_name passed requests the correct resource
Failure/Error: @client.friends("sferik")