Skip to content

Instantly share code, notes, and snippets.

View netshade's full-sized avatar
🧛

Chris Zelenak netshade

🧛
View GitHub Profile
@netshade
netshade / gist:976469
Created May 17, 2011 13:33
Rounded Rect View
//
// RoundedRectView.m
//
//
#import "RoundedRectView.h"
@implementation RoundedRectView
@synthesize backgroundFillColor;
@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: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"
}
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 / 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;
@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 / 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: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 / gist:1424924
Created December 2, 2011 21:33
Compile libdispatch on Ubuntu from source
sudo apt-get install clang subversion autogen libtool pkg-config
svn co svn://mark.heily.com/libBlocksRuntime/trunk libBlocksRuntime
cd libBlocksRunTime
CC=clang ./configure
make
sudo cp libBlocksRuntime.so /usr/local/lib/
sudo cp Block*.h /usr/local/include/
cd ..
svn checkout svn://mark.heily.com/libkqueue/trunk libkqueue
cd libkqueue
@netshade
netshade / gist:1566141
Created January 5, 2012 17:04
metrics from stdin to instrumental
#!/usr/bin/env ruby
# Provide data over STDIN to Instrumental
# Format of data:
# <metric name> <value> <unix timestamp>
# or
# <metric name> <value>
#
# Second form will assume that the time the
# metric is reported is when the event occurred.
#