Skip to content

Instantly share code, notes, and snippets.

View cacheflow's full-sized avatar
🎯
Focusing

Lex Alexander cacheflow

🎯
Focusing
View GitHub Profile
class CreateAuthors < ActiveRecord::Migration
def change
create_table :authors do |t|
t.string :email
t.string :password_digest
t.timestamps
end
end
end
@cacheflow
cacheflow / index.md
Last active August 29, 2015 14:20 — forked from rstacruz/index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@cacheflow
cacheflow / introrx.md
Last active September 20, 2015 09:53 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@cacheflow
cacheflow / dijkstra.rb
Last active August 29, 2015 14:21 — forked from yaraki/dijkstra.rb
#!/usr/bin/ruby1.9.1 -Kw
# -*- coding: utf-8 -*-
class Edge
attr_accessor :src, :dst, :length
def initialize(src, dst, length = 1)
@src = src
@dst = dst
@length = length
@cacheflow
cacheflow / Scrape.rb
Last active August 29, 2015 14:26
Scraping sites
require "nokogiri"
require "open-uri"
page = Nokogiri::HTML(open("http://www.cnn.com"))
gem install nokogiri
page.css("h2.banner").text
page.search("h1", "a").each do |element|
puts element.text
end
Array.prototype.shuffle = function(array_elements) {
var i = array_elements.length, randomNum, randomNumIndex;
while(--i > 0) {
randomNum = Math.floor(Math.random() * (i + 1));
randomNumIndex = array_elements[randomNum];
array_elements[randomNum] = array_elements[i];
array_elements[i] = randomNumIndex;
}
return array_elements;
};
var greeet = "Hello world"
function sayHello() {
console.log(greet)
}