Skip to content

Instantly share code, notes, and snippets.

@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
#
# = Capistrano database.yml task
#
# Provides a couple of tasks for creating the database.yml
# configuration file dynamically when deploy:setup is run.
#
# Category:: Capistrano
# Package:: Database
# Author:: Simone Carletti <weppos@weppos.net>
# Copyright:: 2007-2010 The Authors
class Users::SessionsController < Devise::SessionsController
# Have to reimplement :recall => "failure"
# for warden to redirect to some action that will return what I want
def create
resource = warden.authenticate!(:scope => resource_name, :recall => "failure")
# set_flash_message :notice, :signed_in
sign_in_and_redirect(resource_name, resource)
end
# In all comments :stage represents the stage you want to use (i.e. production, staging, etc.)
# Follow these steps AFTER modifying your /etc/apache2/httpd.conf file to add a new rails instance and running `sudo apachectl restart`
# Steps to setup capistrano for the first time:
# - cap :stage deploy:setup # this creates the correct directory tree
# - cap :stage deploy:check # this checks to make sure setup ran
# - cap :stage deploy:update # this updates the server with the app code
# - ssh :user@:main_server # fill in the correct user and server here
# - cd :deploy_to/current # again fill in the correct deploy to dir
# - RAILS_ENV=:stage sudo rake gems:install # this installs gems that need native compiling
require 'benchmark'
require 'rubygems'
require 'json'
require 'yaml'
include Benchmark
benchmark_iterations = 1
large_single_dimension_array = [42, 123.123] * 5000
large_single_dimension_hash = {}
10000.times do |i|