Skip to content

Instantly share code, notes, and snippets.

Gagan Awhad gaganawhad

View GitHub Profile
View gist:2140121
$ cat /Users/mark/.rvm/log/ruby-1.9.3-p125/autoreconf.log
[2012-03-20 15:09:09] autoreconf
Can't exec "aclocal": No such file or directory at /usr/local/Cellar/autoconf/2.68/share/autoconf/Autom4te/FileUtils.pm line 326.
autoreconf: failed to run aclocal: No such file or directory
View gist:4185221
def do_this
new_array = []
[{"id" => 1,"abbrev" => "GEN","name" => "Genesis","chapters" => 50},{"id" => 2,"abbrev" => "EXO","name" => "Exodus","chapters" => 40},{"id" => 3,"abbrev" => "LEV","name" => "Leviticus","chapters" => 27},{"id" => 4,"abbrev" => "NUM","name" => "Numbers","chapters" => 36},{"id" => 5,"abbrev" => "DEU","name" => "Deuteronomy","chapters" => 34},{"id" => 6,"abbrev" => "JOS","name" => "Joshua","chapters" => 24},{"id" => 7,"abbrev" => "JDG","name" => "Judges","chapters" => 21},{"id" => 8,"abbrev" => "RUT","name" => "Ruth","chapters" => 4},{"id" => 9,"abbrev" => "1SA","name" => "1 Samuel","chapters" => 31},{"id" => 10,"abbrev" => "2SA","name" => "2 Samuel","chapters" => 24},{"id" => 11,"abbrev" => "1KG","name" => "1 Kings","chapters" => 22},{"id" => 12,"abbrev" => "2KG","name" => "2 Kings","chapters" => 25},{"id" => 13,"abbrev" => "1KR","name" => "1 Chronicles","chapters" => 29},{"id" => 14,"abbrev" => "2KR","name" => "2 Chronicles","chapters" => 36},{"id" => 15,"abbrev" => "EZR","name" =
@gaganawhad
gaganawhad / scripture_meta.rb
Created Dec 1, 2012
Meta information about books of the bible / scripture
View scripture_meta.rb
[{"id"=>1,
"abbrev"=>"GEN",
"name"=>"Genesis",
"chapters"=>
[{"id"=>1, "verse_count"=>"31"},
{"id"=>2, "verse_count"=>"25"},
{"id"=>3, "verse_count"=>"24"},
{"id"=>4, "verse_count"=>"26"},
{"id"=>5, "verse_count"=>"32"},
{"id"=>6, "verse_count"=>"22"},
View gist:5207384
[1, 1, 1, 1, 2, 2, 3].to_histogram
=> {1 => 3, 2 => 2, 3 => 1}
@gaganawhad
gaganawhad / activerecord-cheatsheet.md
Last active Aug 27, 2019
Cheatsheet for git, rails, unix etc.
View activerecord-cheatsheet.md

Jsonb AR querying:

  • All records where a particular key is present:

    Groupings::Collection.where("document ? 'name'")

    OR

    Groupings::Collection.where("document ? :key", {key: 'name'}).

@gaganawhad
gaganawhad / i18n conventions.md
Last active Sep 22, 2017
Some conventions / guidelines / best practices that helped me while working on internationalization of a rails app
View i18n conventions.md

Internationalization of a Rails App : conventions / guidelines / best practices

I have worked, and am currently working on internationalization of a Rails app. The apps require translating the ActiveRecord models. I have done some googling, but haven't really found any best practices / conventions / guidelines on how to think through this and what guidelines to follow.

I decided to create this document, to give myself a start and have it possibly help others. I am not an expert at any of this, and there may be things I am thinking incorrectly, but having it documented makes it easier to see the flaws and improve upon. If you have some ideas on additions, or think that somethings should change, get in touch.

Note: I use Globalize for model translations

  • I18n.locale controls the app wide locale. It refers to the particular localization version of the app. It defines how the app is localized to the user. It's scope is somewhat larger than the language/tran
@gaganawhad
gaganawhad / ruby 2.0.0 crash report
Created Jun 17, 2013
I get the following ruby crash report frequently when running rspec. Anyone found any solutions?
View ruby 2.0.0 crash report
Users/gaganawhad/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper: [BUG] Bus Error
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.4.0]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
the more detail of.
@gaganawhad
gaganawhad / passenger-nginx-font-accept-header.md
Last active Jan 22, 2016 — forked from atiw003/nginx-font-serving
Setting Accept-Control-Allow--Origin header on ( font ) assets in nginx. Helpful when using passenger on heroku
View passenger-nginx-font-accept-header.md

Currently passenger 4.0.39 and above come with a default nginx configuration file with a location @static_assets block. Paste the following inside it.

  if ($request_filename ~* ^.*?/([^/]*?)$) {
      set $filename $1; 
   }

  if ($filename ~* ^.*?\.(eot)|(ttf)|(svg)|(woff)$) {
    add_header Access-Control-Allow-Origin *;
  }
View hope-test-4
Name:
Date:
No using computers or google:
For the following 5 questions, chose the option that answers the question.
1. If a variable is named ‘$var’ what type is it ?
@gaganawhad
gaganawhad / insert-rack-auth-digest-md5-middleware.rb
Last active Aug 29, 2015
Setting up Rack::Auth::Digest::MD5 middleware in Rails
View insert-rack-auth-digest-md5-middleware.rb
#References:
# https://github.com/zufrieden/stopwatch/blob/master/config/environments/staging.rb
# http://rubydoc.info/github/rack/rack/Rack/Auth/Digest/MD5
# http://www.sitepoint.com/understanding-http-digest-access-authentication/
# http://levick.tumblr.com/post/65244327897/encrypted-http-basic-auth-in-rails-digest-auth
#"Staging" is the 'realm',
# SecureRandom.base64 is the opaque
# "foo" is the username
You can’t perform that action at this time.