Skip to content

Instantly share code, notes, and snippets.

View amitpatelx's full-sized avatar

Amit Patel amitpatelx

View GitHub Profile
@amitpatelx
amitpatelx / gist:3224238
Created August 1, 2012 06:26
Show overlay to block entire page using jQuery Block plugin
#Ref : http://malsup.com/jquery/block/
$.blockUI({ css:{
width:'100%',
height:'100%',
top:'0',
left:'0',
backgroundColor:'#000',
'-webkit-border-radius':'10px',
'-moz-border-radius':'10px',
@amitpatelx
amitpatelx / stream.rb
Created December 3, 2012 10:41
Cross domain streaming with Goliath
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'goliath'
class RedisPubsub < Goliath::API
use(Rack::Static, :root => Goliath::Application.app_path("public"), :urls => ["/index.html", "/twitter.html", "/favicon.ico", '/stylesheets/', '/javascripts/', '/images/'])
use Goliath::Rack::Params
use Goliath::Rack::Render, 'json'
@amitpatelx
amitpatelx / index.html
Created December 7, 2012 06:07
Websocket with Goliath
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
function WebSocketTest()
{
// let's invite Firefox to the party.
if (window.MozWebSocket) {
window.WebSocket = window.MozWebSocket;
}
@amitpatelx
amitpatelx / Gemfile
Created December 7, 2012 08:53 — forked from gvarela/Gemfile
web sockets with eventmachine and redis pub/sub
# A sample Gemfile
source "http://rubygems.org"
gem "redis"
gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git'
gem "em-hiredis"
# gem "em-synchrony"
gem "em-websocket"
- flash.each do |name, msg|
%div{:class => "alert alert-#{name == :notice ? "success" : "error"}"}
%a.close{"data-dismiss" => "alert"} ×
= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String)
@amitpatelx
amitpatelx / edit.html.haml
Last active December 25, 2015 01:59
Change Password when user logged in. Assumption : Rails + Devise integrated
%h3= t('profile.change_password')
.row-fluid
.span12
.full-graph
.padded
= form_for @user, url: save_password_path, html: {class: 'form-horizontal'} do |f|
.row-fluid
.control-group
%label.control-label Current Password
.controls
@amitpatelx
amitpatelx / Gemfile
Created July 18, 2014 09:53
Rails Developers' Gems for Debugging
group :development do
# rake routes is slow and painful. view routes in browser - http://localhost:3000/rails/routes.
gem 'sextant' #default in Rails 4
# turns off the Rails asset pipeline log. suppresses asset messages in your development log
gem 'quiet_assets'
# powerful alternative to the standard IRB
# features: syntax highlighting, a flexible plugin architecture, runtime invocation and source and documentation browsing.
gem 'pry-rails'

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@amitpatelx
amitpatelx / multiple_properties_single_rate.xml
Last active April 30, 2017 01:10
MultiAvailability Requests
<Head>
<Process DataPath="/HotelML/Form/MultiAvailability" Function="TI_MultiAvailabilityV1_1" Token="300574096589" Timeout="20000" AcceptMultipartResponse="false" />
<Route Destination="00" Source="GI" RequestedAccuracy="CacheOrSource" />
</Head>
<Form>
<MultiAvailability>
<RateCriteria VersionCompliance="Enhanced_V1" MatchingQualifier="ExactOrPublic" NumberOfBeds="1" NumberOfRooms="1" ReturnRateChanges="true" ReturnUnavailable="false">
<GuestCount Type="Adult" Count="1" />
<DateRange InDate="2014-12-30" OutDate="2014-12-31" />
<RateSearch RatePlanCode="RAC" RatePlanType="Standard" />
@amitpatelx
amitpatelx / gist:2b4885144c63359c2e06
Last active August 29, 2015 14:23
Remove Duplicate Active Record Objects
pins = Pin.group(:name).having('count("name") > 1').count(:name)
{"Adam"=>2,
"Beulings"=>2,
"Bord'Eau (Hotel De L'Europe Amsterdam)"=>2,
"Ciel Bleu (Hotel Okura Amsterdam)"=>2,
"Coffee Plaza"=>2,
"Da Portare Via"=>3,
"Dappertutto"=>2,
"En Pluche"=>2,