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
UPDATE table_to_be_updated t1 | |
SET (t1.col1, t1.col2) = | |
(SELECT (t2.col1, t2.col2) subquery_or_table t2 | |
WHERE(t2.id1, t2.id2) in (t1.id1,t1.id2)) | |
WHERE (t1.id1, t1.id2) IN | |
(select t2.id1, t2.id2 from subquery_or_table t2) |
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
public class Matrix { | |
Double[][] data; | |
public Matrix(int m, int n) { | |
data = new Double[n][m]; | |
} | |
Matrix(Double[][] data) { | |
this.data = data; | |
} |
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
# The model here is a two state HMM (States are A and B). | |
# This is a simple network having 4 possible actions, | |
# two for each state (going to the other or staying at the same) | |
# pa and pb are probabilities of having next state as A | |
# from state A and B respectively | |
class Hmm | |
def initialize(pa,pb) | |
@pa = pa; @pb = pb | |
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
def implies(a,b) | |
!(a & !b) | |
end | |
def str(a) | |
a.to_s[0].upcase | |
end | |
def printTable |
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
def har_mean(a) | |
a.size / a.map{|v| 1/v.to_f}.reduce(:+) | |
end | |
puts har_mean([6,9,12]) |
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 "rubygems" | |
require "sequel" | |
require "date" | |
DB = Sequel.connect('jdbc:sqlite:stockinfo.db') | |
DB.create_table? :quote do | |
primary_key :id | |
String :tick | |
DateTime :qdate | |
Float :open |
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 "rubygems" | |
require "sequel" | |
DB = Sequel.connect('jdbc:sqlite:store.db') # | |
all_tables = DB[:sqlite_master] | |
topics = [];goals = [];prev_ind = 0;second_ind = 0 | |
Dir.glob("*.txt").each do |f| | |
IO.readlines(f).each do |line| |
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.each_slice(n).to_a | |
#Source: http://snippets.dzone.com/posts/show/3486 |
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
def sum(arr) | |
res = 0 | |
arr.each{|e| res+=e} | |
res | |
end | |
def mult(arr) | |
res = 1 | |
arr.each{|e| res*=e} | |
res |
NewerOlder