Skip to content

Instantly share code, notes, and snippets.

View xboard's full-sized avatar
🏠
Working from home

Flavio xboard

🏠
Working from home
View GitHub Profile
@xboard
xboard / ssh-tunneling.txt
Created October 13, 2011 13:16
SSH Tunneling
SSH TUNNELING
ssh -f -L 3000:talk.google.com:5222 home -N
I was able to send my Google Talk traffic encrypted through the firewall back to my server at home and then out to Google. All I had to do was reconfigure my Jabber client to use localhost as the server and the port 3000 that I had configured.
@xboard
xboard / bayes_update.R
Created August 17, 2012 20:13 — forked from cjbayesian/bayes_update.R
generate a video demonstrating Bayesian updating
## Corey Chivers, 2012 ##
sim_bayes<-function(p=0.5,N=100,y_lim=20,a_a=2,a_b=10,b_a=8,b_b=3)
{
## Simulate outcomes in advance
outcomes<-sample(1:0,N,prob=c(p,1-p),replace=TRUE)
success<-cumsum(outcomes)
for(frame in 1:N)
{
png(paste("plots/",1000+frame,".png",sep=""))
@xboard
xboard / nnlr
Created April 21, 2014 01:40 — forked from mshivers/nnlr
import scipy as sp
from scipy import optimize as opt
def nnlr(X, y, C):
"""
Non-negative Logistic Regression with L2 regularizer
"""
def lr_cost(X, y, theta, C):
m = len(y)
return (1./m) * (sp.dot(-y, sp.log(sigmoid(sp.dot(X, theta)))) \
@xboard
xboard / MEHMM.py
Created January 2, 2015 03:26
Viterbi algorithm for MEHMM
import numpy as np
class MEHMM(object):
def __init__(self, initialProb, transProb):
self.N = initialProb.shape[0]
self.initialProb = initialProb
self.transProb = transProb
assert self.initialProb.shape == (self.N, )
assert self.transProb.shape == (self.N, self.N)
@xboard
xboard / HMM.py
Created January 2, 2015 13:55
HMM
import numpy as np
class HMM(object):
def __init__(self, initialProb, transProb, obsProb):
self.N = initialProb.shape[0]
self.initialProb = initialProb
self.transProb = transProb
self.obsProb = obsProb
assert self.initialProb.shape == (self.N, 1)
assert self.transProb.shape == (self.N, self.N)
@xboard
xboard / McCannUSAMap
Created April 21, 2015 19:18
USA States McCann-style maps in D3.js
<html>
<head>
<!-- Load the d3 library. -->
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<style>
body { font-family: "Open Sans"; }
text.stateID { dominant-baseline: middle; text-anchor: middle; }
</style>
</head>
"""Kernel K-means"""
# Author: Mathieu Blondel <mathieu@mblondel.org>
# License: BSD 3 clause
import numpy as np
from sklearn.base import BaseEstimator, ClusterMixin
from sklearn.metrics.pairwise import pairwise_kernels
from sklearn.utils import check_random_state
@xboard
xboard / nmf_cd.py
Last active August 29, 2015 14:21 — forked from mblondel/nmf_cd.py
"""
NMF by coordinate descent, designed for sparse data (without missing values)
"""
# Author: Mathieu Blondel <mathieu@mblondel.org>
# License: BSD 3 clause
import numpy as np
import scipy.sparse as sp
import numba
@xboard
xboard / scanner.py
Last active August 29, 2015 14:26 — forked from blinks/scanner.py
A simple Python token scanner.
"""
Scanner: match text to generate tokens.
Adam Blinkinsop <blinks@acm.org>
First, construct a scanner with the tokens you'd like to match described as
keyword arguments, using Python-syntax regular expressions.
WARNING: Group syntax in these expressions has an undefined effect.
>>> simple = Scan(ID=r'\w+')
Verifying that +xboard is my blockchain ID. https://onename.com/xboard