Skip to content

Instantly share code, notes, and snippets.

View mfdela's full-sized avatar

Marco Delaurenti mfdela

View GitHub Profile
@mfdela
mfdela / pearson.rb
Created February 13, 2011 00:37
Pearson produt-moment correlation coefficient
#!/usr/bin/ruby
class Array
def sum
inject( 0 ) { |sum,x| sum+x }
end
def sum_square
inject( 0 ) { |sum,x| sum+x*x }
end
def mean
@mfdela
mfdela / tanimoto.rb
Created February 13, 2011 00:41
Tanimoto coefficient (aka extended Jaccard coefficient) of two real vectors.
#!/usr/bin/ruby
class Array
def sum
inject( 0 ) { |sum,x| sum+x }
end
def sum_square
inject( 0 ) { |sum,x| sum+x*x }
end
def *(other) # dot_product
@mfdela
mfdela / fiber.rb
Created February 13, 2011 00:44
Ruby fiber benchmark
#!/usr/bin/ruby1.9
require 'fiber'
require 'benchmark'
class Ring
attr_reader :id
attr_accessor :attach
def initialize(id)
@mfdela
mfdela / nmf.rb
Created February 13, 2011 00:47
Non-negative matrix factorization
#!/usr/bin/ruby
require("gsl")
def nmf(v, col, thresh)
r, c = v.shape
@mfdela
mfdela / gist:5656719
Created May 27, 2013 12:03
Launching ssh-agent on a remote host and reusing the same agent for all ssh connections.
ssh-launch-agent() {
echo "Starting ssh-agent for remote connection..."
eval `ssh-agent -s -a "$HOME/.ssh/ssh-auth-remote.sock"`
echo $SSH_AGENT_PID > "$HOME/.ssh/ssh-agent-remote.pid"
ssh-add
}
if [ ! -z "$SSH_TTY" ]; then
[ ! -f "$HOME/.ssh/ssh-agent-remote.pid" ] && ssh-launch-agent

Keybase proof

I hereby claim:

  • I am hiraedd on github.
  • I am hiraedd (https://keybase.io/hiraedd) on keybase.
  • I have a public key whose fingerprint is 9118 A943 A992 74BB 83E7 9A00 C5B4 D8E1 DD89 FB2B

To claim this, I am signing this object:

Verifying myself: My Bitcoin username is +hiraedd. https://onename.io/hiraedd

Keybase proof

I hereby claim:

  • I am hiraedd on github.
  • I am hiraedd (https://keybase.io/hiraedd) on keybase.
  • I have a public key whose fingerprint is 3CBF B481 D50D 74BA EA93 2FAD 46B4 5458 85FF 0E17

To claim this, I am signing this object:

@mfdela
mfdela / keybase.md
Last active December 28, 2018 17:25

Keybase proof

I hereby claim:

  • I am mfdela on github.
  • I am mfdela (https://keybase.io/mfdela) on keybase.
  • I have a public key whose fingerprint is FBB0 0CBB A01A 97CD BEBB 0569 58B7 8AF9 DF5D FCC4

To claim this, I am signing this object:

Verifying my Blockstack ID is secured with the address 18oj6YSgJHEoJX3YhopZQiYq1pdpx8TNEe https://explorer.blockstack.org/address/18oj6YSgJHEoJX3YhopZQiYq1pdpx8TNEe