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
# Commands for using postgresql on mac os x (installed via brew). | |
# Start postgresql | |
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start | |
# Status | |
pg_ctl -D /usr/local/var/postgres status | |
# Stop postgresql | |
pg_ctl -D /usr/local/var/postgres stop |
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
fn swap(arr: &mut Vec<int>, i: uint, j: uint) -> &Vec<int> { | |
let buf = arr[i]; | |
arr[i] = arr[j]; | |
arr[j] = buf; | |
arr | |
} | |
fn insertion_sort1(arr: &mut Vec<int>) -> &Vec<int> { | |
for i in range(1, arr.len()) { | |
let key = arr[i]; |
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
puma -w 4 --preload --port 3000 |
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 'matrix' | |
def polynomial_regression x, y, degree | |
rows = x.map do |i| | |
(0..degree).map { |power| (i ** power).to_f } | |
end | |
mx, my = Matrix.rows(rows), Matrix.columns([y]) | |
((mx.transpose * mx).inv * mx.transpose * my).transpose.row(0).to_a.reverse | |
end |
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
ActiveRecord::Base.logger = Logger.new(STDOUT) |
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
SELECT * FROM pg_class, pg_index WHERE pg_index.indisvalid = false AND pg_index.indexrelid = pg_class.oid; |