Skip to content

Instantly share code, notes, and snippets.

View toamitkumar's full-sized avatar
🏠
Working from home

Amit Kumar toamitkumar

🏠
Working from home
View GitHub Profile
@toamitkumar
toamitkumar / gist:955308
Created May 4, 2011 14:27
dynamic routes in unit tests
# Add a controller to test some functionality in controller rspec
class MyTestController < ApplicationController
def index
render :nothing => true
end
end
# add
before do
@toamitkumar
toamitkumar / gist:952211
Created May 2, 2011 19:35
Inspect and test routes on console (Rails 3)
$ rails console
Loading development environment (Rails 3.0.6)
ruby-1.8.7-p334 :001 > r = Rails.application.routes
Gives you a handle of all the routes (config/routes.rb)
#Inspect a named route:
ruby-1.8.7-p334 :005 > r.recognize_path(app.destroy_user_session_path)
=> {:action=>"destroy", :controller=>"sessions"}
@toamitkumar
toamitkumar / gist:951803
Created May 2, 2011 15:44
Controller callbacks
$ rails console
Loading development environment (Rails 3.0.6)
ruby-1.8.7-p334 :001 > class; MyTestController < ApplicationController; end
ruby-1.8.7-p334 :003 > MyTestController._process_action_callbacks.map{|c| c.filter}.compact
=> [:verify_authenticity_token, :authenticate_user!, :first_login?, :secure_from_admin?, :require_current_client]
module Capistrano
class SSH
class << self
alias :original_connect :connect
def connect(server, options={}, &block)
additional_server_settings = options[:server_authentication] ? options[:server_authentication] =~ /#{server.to_s}/ : nil
if additional_server_settings.nil?
return original_connect(server, options, &block)
else
methods = [ %w(publickey hostbased), %w(password keyboard-interactive) ]
Find all the .svn directories:
$ find . -type d -name .svn
./.svn
./directory_1/.svn
./directory_2/.svn
./directory_3/module/.svn
./directory_4/.svn
.......
1) brew install freetds
2) /usr/local/etc/freetds.conf
[my_sql_server]
host = <hostip>
port = 1433
tds version = 7.0
3) Enter these in the Gemfile:
1) Download and install FreeTDS
2) Configure FreeTDS (make an entry inside /usr/local/etc/freetds.conf)
[free_tds_server]
host = <sql server>
port = 1433
tds version = 8.0
encryption = no
The steps for setting *nix server to connect to SQL Server:
1) Install the following binaries:
i) MyODBC-unixODBC
ii) unixODBC
iii) unixODBC-devel
2) Download and install FreeTDS (freetds-dev)
The ./configure step of FreeTDS is dependent on unixODBC being installed: ./configure -with-unixodbc=/usr/local
require File.expand_path(File.dirname(__FILE__) + "/lib/capistrano_extension")
set :server_authentication, <remote user>@<remote server>
We couldn’t find that file to show.