http://guides.rubyonrails.org/migrations.html
- add_column
- add_index
- change_column
- change_table
- create_table
- drop_table
http://guides.rubyonrails.org/migrations.html
const http = require('http'); | |
const url = require('url'); | |
const fs = require('fs'); | |
const path = require('path'); | |
const port = process.argv[2] || 9000; | |
http.createServer(function (req, res) { | |
console.log(`${req.method} ${req.url}`); | |
// parse URL |
#=== Real life examples === | |
graph = RDF::Graph.new | |
# read from file | |
graph = RDF::Graph.load("http://datagraph.org/jhacker/foaf.nt") | |
# -or- from the web | |
graph = RDF::Graph.load("http://dbpedia.org/resource/Elvis_Presley") | |
graph << RDF::RDFa::Reader.open("http://www.bestbuy.com/shop/ipad+xoom+-windows") | |
graph.each_predicate { |s| puts s.inspect } |
http://guides.rubyonrails.org/association_basics.html
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
time node ./lib/permutations.js | |
# getPermutations('abcdefghij') // => abcdefghij, abcdefghji, abcdefgihj, abcdefgijh, abcdefgjhi, abcdefgjih, abcdefhgij... | |
# // n = 10, f(n) = 3,628,800; | |
# ./lib/permutations.js 8.06s user 0.63s system 101% cpu 8.562 total |
getPermutations('ab') // ab, ba... | |
// n = 2, f(n) = 2; | |
getPermutations('abc') // abc, acb, bac, bca, cab, cba... | |
// n = 3, f(n) = 6; | |
getPermutations('abcd') // abcd, abdc, acbd, acdb, adbc, adcb, bacd... | |
// n = 4, f(n) = 24; | |
getPermutations('abcde') // abcde, abced, abdce, abdec, abecd, abedc, acbde... | |
// n = 5, f(n) = 120; |
function getPermutations(string, prefix = '') { | |
if(string.length <= 1) { | |
return [prefix + string]; | |
} | |
return Array.from(string).reduce((result, char, index) => { | |
const reminder = string.slice(0, index) + string.slice(index+1); | |
result = result.concat(getPermutations(reminder, prefix + char)); | |
return result; | |
}, []); |
getPermutations('a') // => [ 'a'] | |
getPermutations('ab') // => [ 'ab', 'ba'] | |
getPermutations('abc') // => [ 'abc', 'acb', 'bac', 'bca', 'cab', 'cba' ] |