Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Gary Haran garyharan

🎯
Focusing
View GitHub Profile
@garyharan
garyharan / split_pushed_commits.sh
Created Feb 24, 2020
Workflow for splitting commits already pushed
View split_pushed_commits.sh
# initiate the change with an interactive rebase from the point you want
git rebase -i SHA^
git reset HEAD^
# do this as many times as you need.
git add -p
git commit -v
# once all your changes are committed
git rebase --continue
@garyharan
garyharan / _mixins.scss
Created May 5, 2011
Useful scss mixins (rounded corners, gradients, text-field, button)
View _mixins.scss
@mixin box-shadow($top, $left, $blur, $color, $inset: false) {
@if $inset {
-webkit-box-shadow:inset $top $left $blur $color;
-moz-box-shadow:inset $top $left $blur $color;
box-shadow:inset $top $left $blur $color;
} @else {
-webkit-box-shadow: $top $left $blur $color;
-moz-box-shadow: $top $left $blur $color;
box-shadow: $top $left $blur $color;
}
@garyharan
garyharan / fix_mac_audio.sh
Created Mar 17, 2020
Restart all core audio when airpods do not work
View fix_mac_audio.sh
# Instead of rebooting system
# If audio has half going through speakers and half going through headphones.
ps aux | grep 'coreaudio[d]' | awk '{print $2}' | xargs sudo kill
@garyharan
garyharan / dot_pryrc
Created Jun 18, 2012
Awesome Print + Pry == Awesome Pry
View dot_pryrc
require "rubygems"
require "awesome_print"
Pry.print = proc { |output, value| output.puts value.ai }
@garyharan
garyharan / colorize.rb
Last active Aug 8, 2019
Simple rails logging output colorize
View colorize.rb
#!/usr/bin/env ruby -w
# SETUP:
# (assumes ~/bin/ is in your path)
# cp colorize.rb ~/bin/colorize
# chmod +x ~/bin/colorize
# USAGE:
# tail -f log/development.log | colorize
class String
@garyharan
garyharan / uncommit_and_stash.sh
Created Feb 7, 2019
How to stash your unpushed commits
View uncommit_and_stash.sh
$ 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 Sep 27, 2018
How to calculate maximum number of processes in Elixir
View maximum_processes.ex
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 Sep 27, 2018
Reaching maximum threads in ruby
View threads_maximum.rb
loop { Thread.new { sleep } rescue puts "Borked at #{Thread.list.count} threads." }
@garyharan
garyharan / grants.sql
Created Nov 27, 2016
How to setup postgresql properly for phoenix defaults
View grants.sql
# 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 / rails_helper.rb
Last active Mar 15, 2017
Speed up tests marginally
View rails_helper.rb
# ...
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
You can’t perform that action at this time.