Skip to content

Instantly share code, notes, and snippets.

View garyharan's full-sized avatar

Gary Haran garyharan

View GitHub Profile
@garyharan
garyharan / uncommit_and_stash.sh
Created February 7, 2019 16:02
How to stash your unpushed commits
$ git status
5 commits pending
$ git reset --soft HEAD~5 # where 5 is the number of commits you saw in the `git status`
$ git stash
@garyharan
garyharan / maximum_processes.ex
Created September 27, 2018 17:51
How to calculate maximum number of processes in Elixir
0..1_000_000
|> Enum.each(fn(_n) ->
IO.puts "Creating process: #{Process.list |> Enum.count}"
spawn(fn -> Process.sleep(:infinity)
end)
end)
@garyharan
garyharan / threads_maximum.rb
Created September 27, 2018 17:25
Reaching maximum threads in ruby
loop { Thread.new { sleep } rescue puts "Borked at #{Thread.list.count} threads." }
@garyharan
garyharan / ELIXIR_PHOENIX_TOOLING.md
Last active December 23, 2016 13:39
Useful resources I found while learning Elixir
@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 / 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;
@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
[filter "hawser"]
clean = git hawser clean %f
smudge = git hawser smudge %f
required = true
[color]
ui = auto
[user]
name = Gary Haran
email = [email protected]
[mergetool "Kaleidoscope"]
@garyharan
garyharan / gist:e680b5a22d9b4d76f0f2
Created February 17, 2015 14:17
When Postgresql complains user does not exist
This can happen when active directory or someone else installed postgresql without proper right like a sudo brew install postgres instead of a brew install postgres.
To fix you can entirely destroy the db and recreate it with your user:
rm -rf /usr/local/var/postgres && initdb /usr/local/var/postgres -E utf8
@garyharan
garyharan / rails
Created July 29, 2014 15:24
/usr/bin/rails
#!/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'railties' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'