Skip to content

Instantly share code, notes, and snippets.

View cactis's full-sized avatar

chitsung.lin cactis

View GitHub Profile
@vjt
vjt / awesome-nginx.conf
Created January 31, 2011 19:43
*AWESOME* nginx configuration for Ruby/Rack web applications
#
# mmm m m mmm mmm mmm mmmmm mmm
# " # "m m m" #" # # " #" "# # # # #" #
# m"""# #m#m# #"""" """m # # # # # #""""
# "mm"# # # "#mm" "mmm" "#m#" # # # "#mm"
#
# nginx configuration For Ruby/Rack web applications
#
# Cooked up with style, care and a bit of *secret*
# nerdy spice. :-)
@scotttam
scotttam / apns.rb
Created January 31, 2012 15:51
Sends an Apple Push Notification with Ruby
require "rubygems"
require "yajl"
require "openssl"
require "socket"
device_token = '39cac56f 986a0e66 3c4fd4f4 68df5598 024d2ca3 8b9f307c 741c180e 9fc30c62'
device_token = device_token.gsub(" ", "")
the_byte_token = [device_token].pack("H*")
file = File.open("ruby_the_byte_token", "wb")
@markrickert
markrickert / webview.m
Created August 21, 2012 20:22
Load RubyMotion links from a UIWebView in Safari
//Here's the same thing in Objective-C
#import "WebView.h"
@implementation WebView
@synthesize webView = _webView;
-(void) viewDidLoad
{
@Bodacious
Bodacious / Rakefile
Created August 23, 2012 11:19
my Rakefile for lastest Rubymotion app
$:.unshift("/Library/RubyMotion/lib")
require File.join(File.dirname(__FILE__), 'version')
require 'motion/project'
require 'bundler'
Bundler.require
@twerth
twerth / example.rb
Created March 23, 2013 17:58
A simple example of creating a UIView with a UICollectionView as a subview in RubyMotion using Teacup for styling
# A simple example of creating a UIView with a UICollectionView as a subview
# in RubyMotion using Teacup for styling
#
# Your controller will need to set the stylesheet: stylesheet :example
# and create this view like so: subview Example, :my_example_view
class Example < UIView
CELL_IDENTIFIER = 'example_cell'
def initWithFrame(frame)
@owenkellogg
owenkellogg / rubymotion_location_bubblewrap.rb
Created May 16, 2013 23:26
rubymotion get location with bubble wrap
BW::Location.get(distance_filter: 10, desired_accuracy: :nearest_ten_meters) do |result|
geocoder = CLGeocoder.alloc.init
geocoder.reverseGeocodeLocation result[:to], completionHandler: lambda {|location, x|
alert = UIAlertView.alloc.init
alert.message = "#{location[0].locality} : #{location[0].postalCode}"
alert.show
}
end
class EventCell < UITableViewCell
IDENTIFIER = 'EventCell'
PADDING = 10
LEFT_MARGIN = 40
RIGHT_MARGIN = 20
attr_reader :event
def initWithStyle(style, reuseIdentifier: reuse_identifier)
super.tap do |cell|
@j4rs
j4rs / instagram.rb
Last active August 5, 2020 20:16
Integrating Instagram(OAuth) using RubyMotion, Promotion, AFMotion and some SugarCube
class Instagram < PM::WebScreen
title "Instagram"
CLIENT_ID = 'your client id'
REDIRECT_URI = 'http://your.domain.com/auth/instagram/callback'
FAILURE_URL = 'http://your.domain.com/auth/failure'
AUTH_URI = "https://instagram.com/oauth/authorize/?client_id=#{CLIENT_ID}&redirect_uri=#{REDIRECT_URI}&response_type=token"
class << self
def api
@chareice
chareice / Rakefile
Created February 8, 2014 06:38
Hide Status Bar in rubymotion
app.info_plist['UIStatusBarStyle'] = 'UIStatusBarStyleBlackTranslucent'
app.info_plist["UIViewControllerBasedStatusBarAppearance"] = false
@jacklynrose
jacklynrose / RubyMotionTheRailsWay.md
Last active August 29, 2015 13:57
Ideas on how to write RubyMotion apps the "Rails" way

RubyMotion The "Rails" Way

This is a current proposal that I'd like your feedback on for how we can clean up how we write RubyMotion applications. It's purely conceptual at the moment, and there would have to be some framework development to make this work the way described here.

Please submit your feedback, as a joint effort we can clean up our RubyMotion applications and make it easier for Rails developers to expand their skills into RubyMotion development.

Goals

The main points of this are: