$ curl -o latest.dump `heroku pgbackups:url -a APPLICATION_NAME`
$ rake db:reset
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U root -d YOUR_LOCAL_DB_NAME latest.dump
$ rm latest.dump
View migrate.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const recast = require('recast'); | |
const types = require('ast-types'); | |
const n = types.namedTypes; | |
const b = types.builders; | |
const filePath = process.argv[2]; | |
const source = fs.readFileSync(filePath); | |
const ast = recast.parse(source); |
View johnson.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Graph() { | |
this.nodes = []; | |
this.arrows = new Map(); | |
} | |
// Tarjan's strongly connected components algorithm | |
Graph.prototype.stronglyConnectedComponents = function tarjan() { | |
var index = 0; | |
var stack = []; | |
var result = []; |
View who-imported.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="node_modules/steal/steal.js"></script> | |
<script> | |
var oldNormalize = System.normalize; | |
System.normalize = function(name, parentName){ | |
return oldNormalize.apply(this, arguments).then(function(name){ | |
if(name === "my/module") { | |
console.log(name, "is imported by", parentName); | |
} | |
return name; | |
}); |
View HW01.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Exercise 1 | |
-- We need to first find the digits of a number. | |
-- Define the functions | |
-- toDigits :: Integer -> [Integer] | |
-- toDigitsRev :: Integer -> [Integer] | |
-- toDigits should convert positive Integers to a list of digits. (For 0 or | |
-- negative inputs, toDigits should return the empty list.) toDigitsRev | |
-- should do the same, but with the digits reversed. |
View functions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// write a function that takes an argument | |
// and returns that argument. | |
function identity(x) { | |
return x; | |
} | |
// write two binary functions, add and mul, | |
// that take two numbers and return their sum and product. |
View best_before.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
def is_valid_date? year, month, day | |
return false if year < 2000 || year > 2999 | |
Date::valid_date?(year, month, day) | |
end | |
class Date | |
def is_valid_date_for_millenium? millenium |
View equilibrium_index
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A zero-indexed array A consisting of N integers is given. | |
An equilibrium index of this array is any integer P such that 0 ≤ P < N | |
and the sum of elements of lower indices is equal to the sum of elements of higher indices, | |
i.e. A[0] + A[1] + ... + A[P−1] = A[P+1] + ... + A[N−2] + A[N−1]. | |
Sum of zero elements is assumed to be equal to 0. This can happen if P = 0 or if P = N−1. | |
For example, consider the following array A consisting of N = 7 elements: | |
A[0] = -7 A[1] = 1 A[2] = 5 |
View falsy_values.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sum = function sum(x, y) { | |
if (!x) { | |
x = 200; | |
} | |
if (!y) { | |
y = 300; | |
} | |
return x + y; |
View pull_heroku.md
View postgresql_setup.md
Original Instructions
http://pragtob.wordpress.com/2012/09/12/setting-up-postgresql-for-ruby-on-rails-on-linux/
sudo apt-get install postgresql
tobi@speedy ~ $ sudo su postgres
[sudo] password for tobi:
postgres@speedy /home/tobi $ createuser tobi(substitute with your username)
Shall the new role be a superuser? (y/n) n
NewerOlder