#Stay Standalone
A short script to prevent internal links to a "webapp" added to iPhone home screen to open in Safari instead of navigating internally.
| /* | |
| Right here's the thing - for keyPress events to be run, you'll have to make use of | |
| content scripts. Content scripts handle things at webpage & DOM level. You'll have | |
| to do changes to your manifest: | |
| */ | |
| ------------------------ | |
| manifest.json: | |
| ------------------------ | |
| /* | |
| Note: don't replace manifest.json, add the relevant changes else |
| class SessionsController < Devise::SessionsController | |
| def create | |
| resource = warden.authenticate!(:scope => resource_name, :recall => :failure) | |
| return sign_in_and_redirect(resource_name, resource) | |
| end | |
| def sign_in_and_redirect(resource_or_scope, resource=nil) | |
| scope = Devise::Mapping.find_scope!(resource_or_scope) | |
| resource ||= resource_or_scope |
#Stay Standalone
A short script to prevent internal links to a "webapp" added to iPhone home screen to open in Safari instead of navigating internally.
| class Api::RegistrationsController < Api::BaseController | |
| respond_to :json | |
| def create | |
| user = User.new(params[:user]) | |
| if user.save | |
| render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
| return | |
| else |
| ############################################################################# | |
| # to use this in jruby: | |
| # | |
| # jgem install sequel | |
| # jgem install jdbc-sqlite3 | |
| # | |
| # for more info on the sequel library, go to http://sequel.rubyforge.org/ | |
| ############################################################################# | |
| require 'rubygems' |
Here's a few things I tried to write output to a python subprocess pipe.
from subprocess import Popen, PIPE
p = Popen('less', stdin=PIPE)
for x in xrange(100):
p.communicate('Line number %d.\n' % x)| class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | |
| def facebook | |
| @user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user) | |
| if @user.persisted? | |
| flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook" | |
| sign_in_and_redirect @user, :event => :authentication | |
| else | |
| session["devise.facebook_data"] = request.env["omniauth.auth"] | |
| redirect_to new_user_registration_url |
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |