Skip to content

Instantly share code, notes, and snippets.

View lklacar's full-sized avatar

Luka Klacar lklacar

View GitHub Profile
@lklacar
lklacar / index.md
Created February 22, 2017 12:48 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

import re
# Supported tokens and their operations
ORDER_OF_OPERATIONS = ["MULTIPLY", "DIVIDE", "ADD", "SUBTRACT"]
scanner = re.Scanner([
(r"([0-9]+)", lambda x, y: int(y)),
(r"\+", lambda x, y: "ADD"),
(r"-", lambda x, y: "SUBTRACT"),
(r"\*", lambda x, y: "MULTIPLY"),
(r"/", lambda x, y: "DIVIDE"),
@lklacar
lklacar / object-watch.js
Created April 7, 2016 14:57 — forked from eligrey/object-watch.js
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/