Skip to content

Instantly share code, notes, and snippets.

View ZenMilan's full-sized avatar

Milan Rawal ZenMilan

View GitHub Profile
@ZenMilan
ZenMilan / rails_load_path_tips.md
Created September 12, 2018 06:15 — forked from maxim/rails_load_path_tips.md
How to use rails load paths, app, and lib directories.

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@ZenMilan
ZenMilan / __readme.md
Created September 12, 2018 06:14 — forked from maxivak/__readme.md
Load code in libraries in Rails 5

Load lib files in production (Rails 5)

If you have your code defined in classes in lib/ folder you may have problems to load that code in production.

Autoloading is disabled in the production environment by default because of thread safety.

Change config/application.rb:

    config.autoload_paths << Rails.root.join("lib")
 config.eager_load_paths &lt;&lt; Rails.root.join("lib")
@ZenMilan
ZenMilan / rails_migration_cheatsheet.md
Created September 4, 2018 09:34 — forked from amejiarosario/rails_migration_cheatsheet.md
Rails Migration - Cheatsheet
@ZenMilan
ZenMilan / RAILS_CHEATSHEET.md
Created September 4, 2018 09:32 — forked from mdang/RAILS_CHEATSHEET.md
Ruby on Rails Cheatsheet

Ruby on Rails Cheatsheet

Architecture

Create a new application

Install the Rails gem if you haven't done so before

@ZenMilan
ZenMilan / fish_shell.md
Created August 7, 2018 04:42 — forked from idleberg/fish_shell.md
Instructions on how to install Fish shell on Mac OS X, including Oh My Fish!. Also includes several useful functions.

Installation

  1. Install fish via Brew
  2. Optionally install Oh My Fish!
  3. Add fish to known shells
  4. Set default shell to fish
brew install fish  
curl -L https://get.oh-my.fish | fish
@ZenMilan
ZenMilan / server_setup_readme.md
Created June 23, 2018 14:12 — forked from yosukehasumi/readme.md
DigitalOcean Rails/Ubuntu/NGINX (16.04) Setup

DigitalOcean Rails/Ubuntu/NGINX (16.04) Setup

  1. Setup
  2. Swapfile
  3. NGINX
  4. ElasticSearch
  5. RVM
  6. Rails
  7. Postgres
  8. Capistrano
@ZenMilan
ZenMilan / ar_arel_wrapper.rb
Created June 14, 2018 11:11 — forked from tokland/ar_arel_wrapper.rb
Simple wrapper over arel
require 'active_record'
require 'arel'
# Ruby-like syntax in AR conditions using the underlying Arel layer (Rails >= 3.0).
#
# What you would usually write like this:
#
# User.where(["users.created_at > ? AND users.name LIKE ?", Date.yesterday, "Mary"])
#
# can now be written like this (note those parentheses required by the operators precedences):
@ZenMilan
ZenMilan / hosting-on-github.md
Created May 8, 2018 08:17 — forked from TylerFisher/hosting-on-github.md
Basic steps for hosting on Github

Steps for Hosting a Website on GitHub

  1. Create a GitHub account on github.com.
  2. Download either [GitHub for Mac][1] or [GitHub for Windows][2], depending on your operating system. Open the app and log in using the account you just created.
  3. (On Mac): After you login, click advanced and make sure that your name and email are correct. Then, click "Install Command Line Tools", just in case you want to start using the command line later in life.
  4. Create a new repository in your GitHub application. Name it your-username.github.io. The name is very important. Note the folder that GitHub is saving the repository to. Make sure the "Push to GitHub?" box is checked.
  5. Move your website's files into the folder that GitHub just created when you made the repository. IMPORTANT: Your homepage HTML file must be called "index.html", and it must exist in the top-level directory.
  6. Back in the GitHub application, you should see your files in the left column. Make sure they are all checked. If so, enter a mess
@ZenMilan
ZenMilan / flexible interface.rb
Created April 17, 2018 15:33 — forked from theHamdiz/flexible interface.rb
Learn how to build flexible interfaces using instance_eval in #ruby
class Person
def name(n)
@name = n
self
end
def age(a)
@age = a
self
end
@ZenMilan
ZenMilan / .irbrc
Created March 16, 2018 08:20 — forked from amokan/.irbrc
my .irbrc file
# Info/code for this file were borrowed from the following places:
# http://bit.ly/174dkWL
# https://gist.github.com/adamcrown/932231
# https://gist.github.com/patmcnally/893833
begin
# ansi colors
ANSI = {}
ANSI[:RESET] = "\e[0m"