Skip to content

Instantly share code, notes, and snippets.

View zmajstor's full-sized avatar

Zoran Majstorovic zmajstor

View GitHub Profile
@mdaguete
mdaguete / Delegate.m
Created December 20, 2011 22:23
APNS Util
/**
* This is what you need to add to your applicationDidFinishLaunching
*/
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
// Add registration for remote notifications
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
// Clear application badge when app launches
@brcosm
brcosm / apns.rb
Created September 13, 2011 02:41
Ruby Apple Push Notification Example
require 'openssl'
require 'socket'
require 'rubygems'
require 'json'
# Takes json as an input and sends data to APNS over SSL
APNS_HOST = 'gateway.sandbox.push.apple.com'
APNS_PORT = 2195
APNS_CERT_FILE_PATH = 'MyCert.pem'
@crosebrugh
crosebrugh / gist:1128448
Created August 5, 2011 20:34
Using nested_form_for with rails_admin
class Product < ActiveRecord::Base
has_many :material_product_mappings, :dependent => :destroy, :inverse_of => :product
has_many :materials, :through => :material_product_mappings, :autosave => true
#...
rails_admin do
list do
field :material_product_mappings do
@jphpsf
jphpsf / application.html.erb
Created July 16, 2011 05:48
Reuse of the Rails Admin layout for the whole application
# app/views/layouts/application.html.erb
<% head_style 'styles' %>
<% head_javascript 'application' %>
<%= render :file => 'layouts/rails_admin/main' %>
@macek
macek / 20101004063749_create_photos.rb
Created October 4, 2010 22:38
How to save uploaded files to your database in Rails
# db/migrate/20101004063749_create_photos.rb
class CreatePhotos < ActiveRecord::Migration
def self.up
create_table :photos do |t|
t.string :name, :null => false
t.binary :data, :null => false
t.string :filename
t.string :mime_type
t.timestamps