Skip to content

Instantly share code, notes, and snippets.

device_token = '123abc456def'
APNS.send_notification(device_token, 'Hello iPhone!' )
#or
APNS.send_notification(device_token, :alert => 'Hello iPhone!', :badge => 1, :sound => 'default')
APNS.send_notification(device_token, :alert => 'Hello iPhone!', :badge => 1, :sound => 'default',
:other => {:sent => 'with apns gem'})
{"aps":{"alert":"Hello iPhone!","badge":1,"sound":"default"},"sent":"with apns gem"}
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge)];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSLog(@"deviceToken: %@", deviceToken);
}
## FRONT END SERVER
location ^~ /progress {
proxy_pass_header X-Progress-ID;
proxy_pass_header X-Request-With;
proxy_pass http://174.129.123.123;
break;
}
location /videos {
require 'rubygems'
require 'png'
class PNGGradient
def initialize(w, h, ca1, ca2)
@w = w
@h = h
Array === ca1 ? @ca1 = ca1 : @ca1 = ca1.hex2dec
Array === ca2 ? @ca2 = ca2 : @ca2 = ca2.hex2dec
get %r{^/(\d{1,3})/(\d{1,3})/([0-9A-Fa-f]{6,6})/([0-9A-Fa-f]{6,6})/output.(\w+)$} do |height, width, color1, color2, type|
case type
when "png"
headers 'Content-Type' => 'image/png'
png_gradient = PNGGradient.new(width.to_i, height.to_i, "##{color1}", "##{color2}")
png_gradient.to_blob()
when "html"
@height, @width, @color1, @color2 = height, width, color1, color2
haml :png, :layout => false
else
#!/usr/local/bin/macruby
require 'hotcocoa'
framework 'webkit'
include HotCocoa
application :name => "Test" do |app|
app.delegate = self
window :frame => [100, 100, 500, 500], :title => "Test" do |win|
@web_view = web_view(:layout => {:expand => [:width, :height]})
win << @web_view
- (void)getUsers
{
var request = [CPURLRequest requestWithURL:baseURL + "/users.json"];
[request setHTTPMethod: "GET"];
addConnection = [CPURLConnection connectionWithRequest:request delegate:self];
}
#!/usr/local/bin/macruby
framework 'AppKit'
class Ftang
def initialize
@app = NSApplication.sharedApplication
win = NSWindow.alloc.initWithContentRect([100, 100, 500, 500],