Skip to content

Instantly share code, notes, and snippets.

View garyharan's full-sized avatar
🎯
Focusing

Gary Haran garyharan

🎯
Focusing
View GitHub Profile
@garyharan
garyharan / .vimrc
Created May 2, 2013 16:59
my .vimrc
set nocompatible " no more legacy
set laststatus=2 " show status lines 2 lines up so I see it
" Vundle specifics
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
Bundle 'gmarik/vundle'
" Bundle 'less.vim'
Bundle 'groenewege/vim-less'
@garyharan
garyharan / everything_is_an_object.rb
Created May 6, 2013 13:51
Just to show a few students a little more about objects
# encoding: UTF-8
#
# I realized objects were hard to grasp
# You already understood the building blocks of programs(String, Fixnumb, Array, Hash)
#
# Look at the following to see what you can learn:
s1 = 'String is an object'
s2 = String.new('String is an object')
@garyharan
garyharan / .vimrc
Created July 26, 2013 21:23
Run a single spec block in vim using a named pipe.
" Of course this can be edited to run whatever you want instead of spring and rspec
map <leader>l :w\|:silent exe "! echo \"spring rspec " . "%" . ":" . line('.') . "\" > test-commands"<cr>
@garyharan
garyharan / pcb
Created August 16, 2013 14:22
We use a convention where each branch is created from an issue. This converts the branch to a pull request in a single command.
cp pcb ~/bin/ # where bin is in your $PATH
chmod +x ~/bin/pcb
@garyharan
garyharan / show_hidden_files_in_macos.sh
Created June 27, 2016 17:34
Sgow hidden files in MacOS Finder
defaults write com.apple.finder AppleShowAllFiles YES
@garyharan
garyharan / first_user_in_faq_app.ex
Created December 2, 2016 04:08
How to get the first user in Ecto
Faq.Repo.get(Faq.User, 1)
@garyharan
garyharan / ELIXIR_PHOENIX_TOOLING.md
Last active December 23, 2016 13:39
Useful resources I found while learning Elixir
Repo.update_all(Question, set: [published_at: Ecto.DateTime.utc(:usec)])
@garyharan
garyharan / rails_helper.rb
Last active March 15, 2017 17:06
Speed up tests marginally
# ...
config.before(:suite) do
connection = ActiveRecord::Base.connection
query = connection.tables.map { |t| "ALTER TABLE #{t} SET UNLOGGED;" }.join("\n")
# one line for each foreign_key at the end of your schema.rb
ActiveRecord::Migration.remove_foreign_key "reports", "users"
connection.execute(query)
end
@garyharan
garyharan / grants.sql
Created November 27, 2016 01:31
How to setup postgresql properly for phoenix defaults
# run psql command to get to this
# Replace APP_NAME with application name
grant all privileges on database APP_NAME_dev to postgres;
grant all privileges on database APP_NAME_test to postgres;