Skip to content

Instantly share code, notes, and snippets.

View sonalkr132's full-sized avatar
🐶
‏‏‎

Aditya Prakash sonalkr132

🐶
‏‏‎
View GitHub Profile
@sonalkr132
sonalkr132 / stamp.rb
Created February 18, 2016 14:05
stamp methods to track time
$start_time = Time.now.to_f
def stamp(label = '')
puts "%.3f\t%s" %[
Time.now.to_f - $start_time,
label
]
end
stamp "start"
@sonalkr132
sonalkr132 / user.rb
Last active March 9, 2016 14:33
user.rb
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :user do
sequence(:email) { |n| "example#{n}@example.com" }
sequence(:name) { |n| "name#{n}" }
sequence(:username) { |n| "username#{n}" }
password 'changeme'
password_confirmation 'changeme'
confirmed_at { Time.now }
biography <<-EOS
require 'spec_helper'
describe ConferenceController do
let(:user) { create(:user) }
describe 'testing user' do
it 'checks for admin user' do
expect(user.is_admin).to be_falsey
sign_in user
expect(controller.current_user).to be_truthy
@sonalkr132
sonalkr132 / cloc-git
Created March 20, 2016 17:24
Count number of line on github repo
#!/usr/bin/env bash
git clone --depth 1 "$1" temp-linecount-repo &&
printf "('temp-linecount-repo' will be deleted automatically)\n\n\n" &&
cloc temp-linecount-repo &&
rm -rf temp-linecount-repo
@sonalkr132
sonalkr132 / bundler-api-setup.md
Last active May 26, 2016 12:07
Setting up bundler-api
# install dependencies
$ sudo dnf install memcached redis

# start redis server
$ redis-server

# start memcached
$ service memcached start
@sonalkr132
sonalkr132 / kill_puma.sh
Created March 23, 2016 14:32
Find and kill
lsof -i :5000
sudo kill -9 <pid>
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\] \[\033[33;1m\]\w\[\033[m\] (\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)) \$ "
# gives me:
wayne ~/dev/lrn (master) $ # my name in green, curr dir in yellow, and branch in green
[user]
name = Aditya Prakash
email = aditya.prakash132@gmail.com
[alias]
co = checkout
s = status
c = commit
lo = log --oneline -10
l = log --oneline
p = push
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:create
** Invoke db:drop (first_time)
** Invoke db:load_config
** Execute db:drop
** Invoke db:setup (first_time)
** Invoke db:schema:load_if_ruby (first_time)
** Invoke db:create
@sonalkr132
sonalkr132 / rake-test.sh
Created May 10, 2016 16:40
Run single file with rake
rake test TEST=path_to_file