Skip to content

Instantly share code, notes, and snippets.

View domluna's full-sized avatar
🐺
howling time

Dominique Luna domluna

🐺
howling time
View GitHub Profile
@domluna
domluna / pagerank.jl
Created October 12, 2014 18:36
Simple pagerank in Julia
# Simple pagerank implementation
# M - transition matrix
# r - initial rankings
# \beta - the taxation cost, (1-\beta) is the teleport prob
# iter - iterations to run for
function pagerank(M::Matrix{Float64}, r::Vector{Float64}, β::Float64, iter::Int64)
c = (1-β)/length(r)
v_prime = β*M*r + c
for i = 1:iter
v_prime = β*M*v_prime + c
@domluna
domluna / matching.py
Last active August 29, 2015 14:07
Matching parens
def match(s, pairs):
stack = []
closers = set(pairs.values())
for c in s:
if c in pairs:
stack.append(pairs[c])
elif c in closers:
# we can end early if either is true
if not stack or c != stack.pop():
@domluna
domluna / lcs.py
Created October 18, 2014 05:12
Longest common substring between two strings
def longest_common_substring(s1, s2):
"""
lcs[i,j] = if match lcs[i-1, j-1] + 1
lcs[i,j] = if not match 0
"""
m = len(s1)
n = len(s2)
# Hash table not be more memory efficient. Here we have n*m
# entries guaranteed. In a hash table all entries that are 0
@domluna
domluna / spiral.py
Created October 18, 2014 18:04
Matrix spiral print
def spiral(M):
"""
Given a matrix M (mxn) print out the elements in spiral order
Ex:
30 42 30 55 31
21 30 60 24 38
11 22 33 44 55
@domluna
domluna / 3_convnet.py
Last active September 6, 2015 21:25
convnet with cgt
from __future__ import print_function, absolute_import
import cgt
from cgt import nn
from cgt.distributions import categorical
import numpy as np
from load import load_mnist
import time
epochs = 10
batch_size = 128
@domluna
domluna / scraper.py
Created September 14, 2015 01:46
HN comment scraper
from __future__ import print_function
from scrapy.selector import Selector
import requests
def scrape_comments(url):
comments = []
r = requests.get(url).text
sel = Selector(text=r)
rough_comments = sel.xpath("//span[@class='comment']/span")
@domluna
domluna / .vimrc
Last active September 17, 2015 21:38
old vimrc. Here just in case I miss something ....
" General
set encoding=utf-8
set fileencoding=utf-8
" Match and Search
set ignorecase
set smartcase
set hlsearch
set incsearch
" set autochdir
set tabstop=4
@domluna
domluna / questions.txt
Created September 21, 2015 05:46
interview questions (if you are the interviewee)
Some questions to ask during interviews:
* What does success look like for this position? How will I know if I am accomplishing what is expected of me?
* What is the last project you shipped? What was the goal, how long did it take, what were the stumbling blocks, what tools did you use, etc.
* What will my first 90 days in this role look like? First 180 days?
* Who will I report to and how many people report to that person? Do they have regular 1:1 with their team members?
* Why did the last person who quit this team leave? The company?
* If a startup, how long is your runway? How are financial decisions made?
* What would be my first project here? Has someone already been working on this or is this in the aspirational stage?
* What is the current state of the data infrastructure? How much work needs to be done on getting the infrastructure and pipeline into shape before we start analyzing that data?
@domluna
domluna / .eslintrc
Created September 24, 2015 19:08
babel eslint setup
{
"parser": "babel-eslint",
"env": {
"node": true,
"mocha": true
},
"rules": {
"brace-style": 2,
"camelcase": 2,
"comma-dangle": [2, "never"],
@domluna
domluna / README
Last active May 3, 2016 06:01
CEM with decreasing noise on CartPole-v0
Implements the Cross-Entropy Method with decreasing noise added to the variance updates as described in [1].
Running cem.py with the default settings should reproduce results.
[1] Szita, Lorincz 2006
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.81.6579&rep=rep1&type=pdf