Skip to content

Instantly share code, notes, and snippets.

View smly's full-sized avatar
👁️‍🗨️

smly smly

👁️‍🗨️
View GitHub Profile
#!perl
use Benchmark qw(:all);
use Digest::MurmurHash3::PurePerl;
use Digest::MurmurHash3;
my $count = 1e7;
cmpthese($count, {
'Digest::MurmurHash3::PurePerl' => sub { Digest::MurmurHash3::PurePerl::murmur32('this is a test. ignore me.') },
th = require 'torch'
mattorch = require 'fb.mattorch'
function main()
train_data = th.load('data/train_all.t7')
test_data = th.load('data/test_all.t7')
print("Convert train_all (mat)")
train_all_mat = {}
for i=1, #train_data do
; Exercise 2.21
(define (square x y) (* x y))
(define (square-list-a items)
(if (null? items)
'()
(cons (* (car items) (car items))
(square-list (cdr items)))))
(define (square-list-b items)
; Exercise 2.20
(define (same-pair x . b)
(define (is-same-parity? x y)
(or (and (even? x) (even? y))
(and (odd? x) (odd? y))))
(define (same-pair-recur items)
(if (null? items)
'()
(if (is-same-parity? x (car items))
(cons (car items) (same-pair-recur (cdr items)))
import Data.List (tails,sort)
-- build suffix array
build :: Ord a => [a] -> [[a]]
build = sort.tails
-- binary search
bs [] str = False
bs [x] str = cmp str x
bs xs str
import System.Posix.Unistd
import System.Posix.Signals
import System.Exit
main = do
let exit0 = exitWith ExitSuccess
let exit1 = exitWith (ExitFailure 1)
installHandler sigINT (Catch exit1) Nothing
sleep 1000000
exit0
#!/usr/bin/env python
# PageRank (on memory)
# using power method
from numarray import *
from numarray.matrix import *
EPS = 1.0e-10
class PageRank():
#!/usr/bin/env python
# HITS (on memory)
from numarray import *
from numarray.matrix import *
EPS = 1.0e-10
class HITS():
def __init__(self, adj_matrix):
#!/usr/bin/env python
# HITS (on memory)
# using co-citation matrix
from numpy import *
from numpy.linalg import *
class HITS():
def __init__(self, adj_matrix):
self._adj = adj_matrix
#!/usr/bin/env python
# HITS (on memory)
# using co-citation matrix
from numpy import *
from numpy.linalg import *
class HITS():
def __init__(self, adj_matrix):
self._adj = adj_matrix