Skip to content

Instantly share code, notes, and snippets.

Code Reloading

The difficulties, or rather impossibilities, of doing in-process code reloading in Ruby have been well-documented.
There are many out-of-process reloading solutions. These all essentially reboot your application, reloading all dependancies.
This provides an obvious incentive to keep your application boot times as fast as possible.

Examples:

'Rerun launches your program, then watches the filesystem. If a relevant file changes, then it restarts your program. By default it watches files ending in: rb,js,coffee,css,scss,sass,erb,html,haml,ru,yml,slim,md,feature. Use the --pattern option if you want to change this.' - Doc U. Mentation Jr.

setTimeout(function () {
(function ($) {
"use strict";
(function ($, window, document, undefined) {
var gridContainer = $('#grid-container'),
filtersContainer = $('#filters-container');
// init cubeportfolio

The jQuery identifier (or $) is just a constructor function, and all instances created with it, inherit from the constructor's prototype.

###A simple constructor function:

function Test() {
  this.a = 'a';
}
Test.prototype.b = 'b';

var test = new Test(); 
---------------- .bash_profile extract ---------------------
# Bash aliases
alias e=subl
alias be="bundle exec"
alias g=git
alias cl=clear
alias gpo="git push origin"
alias gph="git push heroku"
alias rials="rails"
alias gti="git"
@sebabelmar
sebabelmar / Passport Instagram Strategy.js
Created July 6, 2016 07:50
Passport Instagram Strategy for meanjs.or
'use strict';
/**
* Module dependencies.
*/
var passport = require('passport'),
InstagramStrategy = require('passport-instagram').Strategy,
users = require('../../controllers/users.server.controller');
module.exports = function(config) {
table_array = [
["brand", "year", "color"],
["specialized", 2001, "blue"],
["bianchi", 1999, "silver"] ,
["yetti", 2016, "red"]
]
# SYSTEM_SECRET should be equal to THIS_IS_THE_SECRET
THIS_IS_THE_SECRET = 'MY LITTLE SECRET'
# <YOUR NECESSARY CODE>
@sebabelmar
sebabelmar / ruby_closures.rb
Created September 24, 2016 01:56
Thoughts on Ruby Closures
# outer = 1
# def m
# inner = 99
# puts "inner var = #{inner + outer}" # outer is out of reach
# end
# Thinking in JS world in m we have access to outer but in ruby NAH!
# Let's expose inner to outer...
# Bikes Factory
b1 = {brand: "scott", year: 2016, color: "red"}
b2 = {brand: "specialized", year: 2016, color: "blue"}
b3 = {brand: "Releigh", year: 2016, color: "white"}
arr = Bike.create_bikes_array([b1, b2, b3])
# arr = [< Instance of Bike 1>, <Instance of Bike 2>, <Instance of Bike 3>]
# Stretch print: ["scott", "specialized", "Releigh"]
// ----------------------- Driver Code -----------------------
var b1 = {brand: "scott", year: 2016, color: "red"}
var b2 = {brand: "specialized", year: 2016, color: "blue"}
var b3 = {brand: "Releigh", year: 2016, color: "white"}
arr = Bike.create_bikes_array([b1, b2, b3])
console.log(arr); // => [< Instance of Bike 1>, <Instance of Bike 2>, <Instance of Bike 3>]
//Stretch print: ["scott", "specialized", "Releigh"]