Skip to content

Instantly share code, notes, and snippets.

@EmanuelCadems
EmanuelCadems / example_relations.rb
Created February 24, 2017 14:52
Example Relations Order, LineItem, and Product
class Order < ActiveRecord::Base
has_many :line_items
end
class LineItem < ActiveRecord::Base
belongs_to :order
belongs_to :product
end
class Product < ActiveRecord::Base
@EmanuelCadems
EmanuelCadems / my_app.sh
Created February 19, 2017 00:55
How to create multiple folders at the same time
mkdir -p Sree/{Linux/{commands,shellscript},SQL/{basic,advance},DBA/{Oracle,MySQL}}
# the explanation
# mkdir -p Sree/{
# Linux/{
# commands,
# shellscript
# },
# SQL/{
# basic,
@EmanuelCadems
EmanuelCadems / bootstrapCDN.html
Created January 30, 2017 04:12 — forked from planetoftheweb/bootstrapCDN.html
Bootstrap 3 CDN Page Code
<!-- HEAD SECTION -->
<!-- IE Edge Meta Tag -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Viewport -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
@EmanuelCadems
EmanuelCadems / restful.rb
Created October 3, 2016 03:57
Change 'admin/hacker_list' by 'admin/hackers' in order to fowllow Restful conventions
# Following the RESTful conventions. Use 'admin/hackers' instead of 'admin/hacker_list'
# /config/routes.rb
# You can use this one, which allows you to add more routes into the admin namespace.
namespace :admin do
resources :hackers, only: [:index]
end
@EmanuelCadems
EmanuelCadems / ej.rb
Created April 29, 2016 18:06
How to define private method for using into a class method
class Ej
class << self
def bar
my_method
end
private
def my_method
'hola mundo'
end
@EmanuelCadems
EmanuelCadems / watch_me
Last active August 29, 2015 14:24
watch me
https://www.youtube.com/watch?v=HmWm21cCAXM
https://angular.io/docs/js/latest/quickstart.html
https://www.youtube.com/watch?v=XQzehz5i4Rg
@EmanuelCadems
EmanuelCadems / gist:a0a8fde2af269e17f4c9
Last active January 28, 2016 14:15
Notes about installations in Mac Yosemite

General

  • Install xcode

  • Install iTerm

  • Install oh-myzsh

  • Install sublimetext

  • Add alias sublimetext in .zshrc

  • Install brew

  • Install GPG

  • Install rvm (read notes after install), rvm notes, rvm requirements

@EmanuelCadems
EmanuelCadems / console
Created December 27, 2014 01:44
How to install rvm on ubuntu 14.04
24 gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
25 \curl -sSL https://get.rvm.io | bash -s stable
26 sudo apt-get install curl
27 \curl -sSL https://get.rvm.io | bash -s stable
28 rvm --version
29 source /home/emanuel/.rvm/scripts/rvm
30 rvm --version
31 rvm notes
32 rvm --version
33 rvm requirements
@EmanuelCadems
EmanuelCadems / realistic_way.rb
Created October 12, 2014 03:42
Method like a class attribute
module ActionView
module Layouts
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def layout
p 'Hello World'
end
@EmanuelCadems
EmanuelCadems / simple_way.rb
Created October 12, 2014 03:40
method like a class attribute
module ActionController
class Base
def self.layout
p "Hello World"
end
end
end
class ApplicationController < ActionController::Base
layout