Skip to content

Instantly share code, notes, and snippets.

View modules_constants.rb
# SYSTEM_SECRET should be equal to THIS_IS_THE_SECRET
THIS_IS_THE_SECRET = 'MY LITTLE SECRET'
# <YOUR NECESSARY CODE>
View bikes_factory_2.rb
table_array = [
["brand", "year", "color"],
["specialized", 2001, "blue"],
["bianchi", 1999, "silver"] ,
["yetti", 2016, "red"]
]
@sebabelmar
sebabelmar / Passport Instagram Strategy.js
Created Jul 6, 2016
Passport Instagram Strategy for meanjs.or
View Passport Instagram Strategy.js
'use strict';
/**
* Module dependencies.
*/
var passport = require('passport'),
InstagramStrategy = require('passport-instagram').Strategy,
users = require('../../controllers/users.server.controller');
module.exports = function(config) {
View .gitconfig
---------------- .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"
View some_fun.rb
# 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"]
View jQuery-structure.md

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(); 
View wtf.js
setTimeout(function () {
(function ($) {
"use strict";
(function ($, window, document, undefined) {
var gridContainer = $('#grid-container'),
filtersContainer = $('#filters-container');
// init cubeportfolio
View sinatra_code_reload.md

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

> '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.

View phase-2-sinatra.md

Ain't she sweet?!

Database Level

The skeletton that we used today has a connection on config/database.rb to a posgress DB if there is not set by ENV variable:

db = URI.parse(ENV['DATABASE_URL'] || "postgres://localhost/#{APP_NAME}_#{Sinatra::Application.environment}")

In that same file you can see that we set:

DB_NAME = db.path[1..-1]
View using_yield.rb
def do_twice
yield
yield
end
# The basics
do_twice {puts "HOLA"}
def do_something_to_an_array (array)