Skip to content

Instantly share code, notes, and snippets.

View netshade's full-sized avatar
🧛

Chris Zelenak netshade

🧛
View GitHub Profile
@netshade
netshade / gist:1374899
Created November 17, 2011 23:18
JSONP Twitter Search
<html>
<head>
<script type="text/javascript">
function showStories(the_object){
var titles = [];
for(var i = 0; i < the_object.results.length; i++){ // the object coming back from twitter is an object that contains the results in a member named results
titles.push("<li>" + the_object.results[i].text + ": " + the_object.results[i].from_user_name + "</li>");
}
document.getElementById("story_list").innerHTML = titles.join("\n");
}
@netshade
netshade / gitstrumental
Created November 8, 2011 05:00
Push git commit info to Instrumental
#!/usr/bin/env ruby
require 'rubygems'
gem 'instrumental_agent'
require 'instrumental_agent'
if !ARGV[0]
puts 'Usage: gitstrumental API_TOKEN'
exit 1
end
@netshade
netshade / gist:1226713
Created September 19, 2011 15:08
God crash
F [2011-09-09 20:55:47] FATAL: Unhandled exception (StandardError): No buffer space available
/usr/lib/ruby/gems/1.8/gems/god-0.11.0/bin/../lib/god/event_handler.rb:62:in `handle_events'
/usr/lib/ruby/gems/1.8/gems/god-0.11.0/bin/../lib/god/event_handler.rb:62:in `start'
/usr/lib/ruby/gems/1.8/gems/god-0.11.0/bin/../lib/god/event_handler.rb:60:in `loop'
/usr/lib/ruby/gems/1.8/gems/god-0.11.0/bin/../lib/god/event_handler.rb:60:in `start'
/usr/lib/ruby/gems/1.8/gems/god-0.11.0/bin/../lib/god/event_handler.rb:59:in `initialize'
/usr/lib/ruby/gems/1.8/gems/god-0.11.0/bin/../lib/god/event_handler.rb:59:in `new'
/usr/lib/ruby/gems/1.8/gems/god-0.11.0/bin/../lib/god/event_handler.rb:59:in `start'
/usr/lib/ruby/gems/1.8/gems/god-0.11.0/bin/../lib/god/cli/run.rb:70:in `default_run'
/usr/lib/ruby/gems/1.8/gems/god-0.11.0/bin/../lib/god/cli/run.rb:100:in `run_daemonized'
@netshade
netshade / american _why
Created August 24, 2011 18:52
_catch the lucky whiff's tribute to _why
A long, long time ago...
I can still remember
How his blog used to make me smile.
And I knew that if he had his chance
That he could make their code enhance
And, maybe, they’d be happy for a while.
But August made me shiver
With every code line I’d deliver.
Bad news on the doorstep;
Just a thought experiment on how to identify a phone's iTunes user account as they migrate from phone to phone ( they have to have purchased an IAP item from you ).
The first time someone buys an IAP item from you, they'll create an SKPayment with you. If you add it to an SKPaymentQueue, this payment is now tied directly to your app bundle identifier and the iTunes account. So long as you NEVER call finishTransaction: on the resultant SKPaymentTransaction, iTunes will try to restore this payment in your app as the iTunes account of the user migrates from phone to phone. I believe you could try to do something similar with SKPaymentTransaction's originalTransactions property, such that instead of leaving a payment constantly in the queue, you always call restoreTransactions at the start of your app, and inspect the originalTransaction property's transaction id ( compared w/ some stored transaction id you have on your own server to support migrating all associated data w/ the iTunes account ).
Lacking some w
@netshade
netshade / gist:1125810
Created August 4, 2011 18:15
git stash grep for zsh
stashgrep() {
for i in `git stash list | awk -F ':' '{print $1}'`; git stash show -p $i | grep -H --label="$i" "$1"
}
@netshade
netshade / lighting.vsh
Created June 22, 2011 15:56
Vertex and Fragment shaders
// VERTEX SHADER
//
// Lighting.vsh
const int MaxLights = 3;
struct Light {
highp vec3 position;
@netshade
netshade / gist:976469
Created May 17, 2011 13:33
Rounded Rect View
//
// RoundedRectView.m
//
//
#import "RoundedRectView.h"
@implementation RoundedRectView
@synthesize backgroundFillColor;
@netshade
netshade / URL Redirection bug on Mobile Safari
Created February 17, 2011 15:05
Twitter Authorize-App "Don't Have a Twitter account" misdirection when using Mobile Safari
If you attempt to authorize an app to access your Twitter account using a Mobile Safari user-agent and arrive at the "Allow" / "Deny" screen while not currently logged in at Twitter, you are presented with a link that says "Don't have a Twitter account? Sign up Now!" . This link forwards you to:
http://api.twitter.com/account/new?oauth_token=<the-oauth-token-for-the-session>
which subsequently forwards you to:
http://mobile.twitter.com/account/new
which then forwards you to:
/*
With an open path this yields less than desirable results;
closed paths this technique should be fine with.
Screenshot: http://tinypic.com/view.php?pic=7301up&s=7
*/
- (void)drawRect:(CGRect)rect {
UIImage * bg = [UIImage imageNamed:@"bg.png"];
CGContextRef context = UIGraphicsGetCurrentContext();