Skip to content

Instantly share code, notes, and snippets.

View prathamesh-sonpatki's full-sized avatar
🏠
Working from home

प्रथमेश Sonpatki prathamesh-sonpatki

🏠
Working from home
View GitHub Profile
@prathamesh-sonpatki
prathamesh-sonpatki / 1.1.1_atoms.el
Last active December 11, 2015 08:08
Code examples from book "An Introduction to Programming in Emacs Lisp"
;; 1.1.1 Lisp atoms
;; If a list is preceded by single quote, we are telling lisp interpreter to take it as it is
'(sachin
rahul
saurav
laxman)
;; If a list is not preceded by single quote, lisp interpreter treats first atom of the list as a function,
;; and passes all the remaining atoms as arguments to it, and returns result of the function
(+ 2 2)
'(this list has (list inside it))
-T
-d postgresql
def change_log(stream)
# send Rails logs to console
# 2.X
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER')
require 'logger'
Object.const_set 'RAILS_DEFAULT_LOGGER', Logger.new(stream)
end
# Fake email id generator for Gmail
# These emails will come to real email id you have provided to this script
require 'csv'
def generate_fake_emails(email, count = 1)
result = []
username, domain = email.split('@')
count.times do |c|
result << "#{username}+#{c+1}@#{domain}"
describe "get Custom Domain name" do
it "gives custom domain name from the url" do
get_custom_domain("http://facebook.com").should == "facebook.com"
get_custom_domain("https://gist.github.com").should == "gist.github.com"
get_custom_domain("http://www.github.com").should == "github.com"
get_custom_domain("www.google.com").should == "google.com"
get_custom_domain("http://examplesitewww.com").should == "examplesitewww.com"
get_custom_domain("http://examplehttp.com").should == "examplehttp.com"
get_custom_domain("").should == ""
end
* Rails code-reading activity @ Open Source Friday
** For understanding what we do day to day in a better way,
** We will open up Rails codebase,
** And will go through the code,
** To understand the structure of Rails,
** To learn what, where, how it works,
** To contribute back in terms of documentation and bug-fixes and features!
* Useful links
@prathamesh-sonpatki
prathamesh-sonpatki / jenkins_setup.sh
Created April 21, 2013 03:08
Steps to install and setup on Jenkins on Fedora/CentOS
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install jenkins
sudo service jenkins start/stop/restart
sudo service jenkins start
sudo usermod -s /bin/bash jenkins
sudo usermod -m /var/lib/jenkins jenkins
sudo su - jenkins
curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled
vi /var/lib/jenkins/.bashrc
# Packages and modules are imported to the scope using the import statement.
# If you wanted just a particular object from a module/package you can use
# the from <module> import <object>
import sys
import requests
# There are no constants in Python, still we can use a naming convention to
# imply that to the user of a library.
BASE_URL = "https://api.github.com"
source $HOME/.bashrc
rvm use 1.9.3
bundle install
read -d '' database_yml <<"EOF"
login: &login
adapter: "postgresql"
encoding: utf8
username: "postgres"
password: "postgres"
@prathamesh-sonpatki
prathamesh-sonpatki / joy.coffee
Created May 11, 2013 03:43
coffeescript is awesome
# Fill out the form with company attributes
attributes = ['name', 'website', 'phone', 'address', 'country', 'state', 'city', 'zip']
for attr in attributes
$("#company_#{attr}").val(company["#{attr}"])
a = ["Ruby", "Python", "Clojure"]
#=> ["Ruby", "Python", "Clojure"]
a.to_sentence
#=> "Ruby, Python, and Clojure"