Skip to content

Instantly share code, notes, and snippets.

View psahni's full-sized avatar

Prashant Sahni psahni

View GitHub Profile
@psahni
psahni / 01-intro.md
Last active August 29, 2015 14:14 — forked from dwayne/01-intro.md

Introduction

Author: Ari Lerner.

AngularJS offers a single framework that can be used to build dynamic, client-centric applications. It provides:

  • Module support
  • DOM manipulation
  • Animations
  • Templating
@psahni
psahni / deploy.rb
Created August 24, 2012 13:15 — forked from markoa/deploy.rb
Ingredients to monitor Resque with God automatically via Capistrano (on Ubuntu)
namespace :deploy do
desc "Hot-reload God configuration for the Resque worker"
task :reload_god_config do
sudo "god stop resque"
sudo "god load #{File.join(deploy_to, 'current', 'config', 'resque-' + rails_env + '.god')}"
sudo "god start resque"
end
end
# append to the bottom:
require 'spec_helper'
feature "Editing tickets" do
let!(:project) { Factory(:project) }
let!(:ticket) { Factory(:ticket, :project => project) }
before do
visit '/'
click_link project.name
click_link ticket.title
Animals.each do |letter, results|
10.times do
doc = Nokogiri::HTML(open("http://www.ocar.org/page.php?tut=realtor-affiliate-search-results&tid=802&pid=8&first_or_last_name=#{letter}&city=&office=&btc=&op=find_a_realtor&ftut=find-a-realtor&start=#{results_per_page}"))
realtors = {}
('a'..'z').each do |n|
realtors[n] = Realtor.create
end
doc.css('div.search_results_item').each do |number|
phone_number = /\(\d{3}\)\s\d{3}-\d{4}/.match("#{number.content}")
('a'..'z').each do |n|
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {
@psahni
psahni / application.html.erb
Created August 3, 2011 06:48 — forked from chrisbloom7/application.html.erb
Static named redirect routes in Rails 3
<ul class="social-links">
<li class="facebook"><%= link_to "Like us on Facebook", facebook_path %></li>
<li class="twitter"><%= link_to "Follow us on Twitter", twitter_path %></li>
</ul>
@psahni
psahni / mysql_connection_cleaner.rb
Created June 15, 2011 13:02 — forked from jagira/mysql_connection_cleaner.rb
MySQL Connection Cleaner
require 'mysql2'
client = Mysql::Client.new(:host => "localhost", :username => "root")
# Fetch running threads
processes = client.query("SHOW FULL PROCESSLIST")
processes.each do |process|
# Kill thread
class Article
attr_reader :filename
def initialize(filename)
@filename = filename
end
def <=> other
self.filename <=> other.filename
end