Skip to content

Instantly share code, notes, and snippets.

View jay3126's full-sized avatar

Janmejay Rai (Jay) jay3126

View GitHub Profile
@jay3126
jay3126 / pre-commit.sh
Created February 2, 2012 12:52 — forked from yeban/pre-commit.sh
Git pre-commit hook to remove stray debugger statements from your merb project.
#!/bin/sh
# Remove stray debugger statements from the modified files before committing
# get a list of added, modified, copied files
files=`git diff --cached --name-only --diff-filter=ACM`
# remove debugger lines
#
# 1. remove any line containing a debugger
@jay3126
jay3126 / pre-commit.sh
Created February 2, 2012 12:52 — forked from yeban/pre-commit.sh
Git pre-commit hook to remove stray debugger statements from your merb project.
#!/bin/sh
# Remove stray debugger statements from the modified files before committing
# get a list of added, modified, copied files
files=`git diff --cached --name-only --diff-filter=ACM`
# remove debugger lines
#
# 1. remove any line containing a debugger
#!/usr/bin/env ruby
require "nokogiri"
require "open-uri"
def download(url, output_file)
exit unless system("wget -c #{url} --load-cookies=cookies.txt -O #{output_file}")
end
def download_pages
#!/usr/local/bin/ruby
# A script to download the latest episodes from railscasts.com
#
# author: modsaid <mahmoud@modsaid.com>
# mechanize support: Hossam Hammady <github@hammady.net>
# gem install mechanize
require 'rubygems'
require 'mechanize'
#!/usr/bin/ruby
require 'rss'
p 'Downloading rss index'
rss_string = open('http://feeds.feedburner.com/railscasts').read
rss = RSS::Parser.parse(rss_string, false)
videos_urls = rss.items.map { |it| it.enclosure.url }.reverse
videos_filenames = videos_urls.map {|url| url.split('/').last }
require 'rss'
require 'open-uri'
p "Downloading rss index"
# If you are a Railscasts Pro subscriber, you will have a different RSS feed with Pro casts
# If this is the case, go to http://railscasts.com/, find it and sub it below
rss_string = open('http://feeds.feedburner.com/railscasts').read
rss = RSS::Parser.parse(rss_string, false)
videos_urls = rss.items.map { |it| it.enclosure.url }.reverse
require "rubygems"
require "octokit" # gem install octokit
1.upto(5) do |page|
Octokit.repositories("railscasts", page: page, per_page: 100).each do |repo|
system "git clone git://github.com/railscasts/#{repo.name}"
end
end
@jay3126
jay3126 / postgres-cheatsheet.md
Last active August 29, 2015 14:26 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

Magic words:

psql -U postgres

Most \d commands support additional param of __schema__.name__ and accept wildcards like *.*

  • \q: Quit/Exit
  • \c __database__: Connect to a database
  • \d __table__: Show table definition including triggers
@jay3126
jay3126 / .bashrc
Created January 5, 2016 10:18 — forked from vsouza/.bashrc
Golang 1.5 setup in Mac OSX with HomeBrew. Set `GOPATH` and `GOROOT` variables in zshell or bash.
# Set variables in .bashrc file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
@jay3126
jay3126 / rpg.rb
Created February 29, 2016 18:56 — forked from theHamdiz/rpg.rb
Random Password Generator Ruby Module
module RandomPassword
def generate
# create a one big array of seeding data
seed = [('a'..'z'), ('!'..'+'), (1..9), ('A'..'Z')].map { |e| e.to_a }.flatten
# get random 16 characters from this array
original = (0..16).map { seed[rand(seed.length)] }.join
# just to be sure, randomize them once more
original.split('').shuffle.join
end
end