Skip to content

Instantly share code, notes, and snippets.

View vishnugopal's full-sized avatar
🇮🇳

Vishnu Gopal vishnugopal

🇮🇳
View GitHub Profile
@vishnugopal
vishnugopal / force_ssl.rb
Created September 17, 2012 17:34
Force SSL for a particular action
class SessionController
before_filter :force_ssl, :only => :create
# login
def new
end
# login
def create
@vishnugopal
vishnugopal / StoryboardDelegate.rb
Created May 23, 2012 17:40
A Rubymotion Storyboard Delegate that automatically loads the initial storyboard (marked with identifier "Start")
class StoryboardDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
storyboard = UIStoryboard.storyboardWithName("Storyboard", bundle: NSBundle.mainBundle)
viewController = storyboard.instantiateViewControllerWithIdentifier("Start")
if self.respond_to?("initializeRootViewController:forApplication:launchedWithOptions:")
viewController = initializeRootViewController(viewController, forApplication:application, launchedWithOptions:launchOptions)
end
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
@vishnugopal
vishnugopal / apple-b2b.txt
Created May 7, 2012 16:31
Apple's B2B program
Sell and Distribute Custom B2B Apps to Business Customers
You can offer custom B2B apps directly to your business customers who have a Volume Purchase Program account. A custom B2B app provides a unique, tailored solution to address a specific business need or requirement.
Some features of a custom B2B app can include:
A personalized UI including company logo or branding
Unique capabilities specific to a business process or workflow
Extra privacy protection to handle sensitive data
A specific configuration to meet the customer’s server/back-office environment or IT environment
Features targeting a limited audience, such as a business partner, dealer, or franchise
You can define the price for the custom B2B app according to the guidelines provided in the latest price schedule. The minimum price for a custom B2B app is $9.99.
<iframe width="560" height="315" src="http://www.youtube.com/embed/4oTMY-KPb0o" frameborder="0" allowfullscreen=true></iframe>
@vishnugopal
vishnugopal / getAuthParameters.java
Created February 15, 2012 11:28
Refactor Java!
private String[] getAuthenticationParameters() throws NoSuchAlgorithmException {
String[] parameters = { "", "" };
MessageDigest md = MessageDigest.getInstance("MD5");
String timestamp = String.valueOf(java.lang.System.currentTimeMillis());
String keyWithTimestamp = timestamp.concat(Constants.RPC.Services.API_KEY);
// Let's generate a hex representation of the hash
// http://stackoverflow.com/a/421696
md.reset();
@vishnugopal
vishnugopal / Gemfile
Created November 28, 2011 10:25
ZeroMQ Example
source :rubygems
gem "ffi"
gem "ffi-rzmq"
@vishnugopal
vishnugopal / Output.txt
Created November 23, 2011 10:25
Convert anything to a Kolaveri song!
Yo boys Jude-la dont-u make it bad-la
Take-la a sad-la song-u and-la make it better-u
Remember-u to let-u her-u into-u your heart-u
Then-u you can-u start-u to make it better-u
Why this kolaveri kolaveri kolaveri di!
Yo boys Jude-la dont-u be afraid-la
You were made-la to go-u out-u and-la get-u her-u
The minute-la you let-u her-u under-u your skin-u
Then-u you begin-u to make it better-u
@vishnugopal
vishnugopal / bluetooth.rb
Created November 8, 2011 16:10
Bluetooth Scan & Send
# From: http://refactormycode.com/codes/1252-bluetooth-device-class
class Device
@@devices = {}
def self.new mac, *args
@@devices[mac] ||= super
end
MAC_PATTERN = /(?:[0-9a-f]{2}\:){5}[0-9a-f]{2}/
@vishnugopal
vishnugopal / Ruby, OSX Version, Notes
Created July 22, 2011 09:26
ruby-1.9.2-p290 Fiber bug on OS X Lion
Miranda ~/Code/Sandbox/ussd-renderer-redux % sw_vers
ProductName: Mac OS X
ProductVersion: 10.7
BuildVersion: 11A511
Miranda ~/Code/Sandbox/ussd-renderer-redux % ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0]
Seems to be similar to (if not solved by): https://github.com/ruby/ruby/commit/be953b4d1ce3f0dfc7f24c84ec7a51e027102557
wc -l 14.csv = 7631928
wc -l base.csv = 1000000
Bitmap:
ruby -rubygems fast_filter_shell.rb add --engine bitmap 14.csv 556.92s user 152.28s system 63% cpu 18:41.26 total
ruby -rubygems fast_filter_shell.rb filter --engine bitmap base.csv 73.79s user 20.08s system 67% cpu 2:18.51 total
Space: 570MB (constant)