Skip to content

Instantly share code, notes, and snippets.

View bnsh's full-sized avatar

Binesh Bannerjee bnsh

View GitHub Profile
static int jaro_winkler_false(const char *a, const char *b) { return(jaro_winkler(a,b, false)); }
static Handle<Value> generic(const Arguments& args, int (*func)(const char *, const char *)) {
HandleScope scope;
if (args.Length() != 2 || !args[0]->IsString() ||
!args[1]->IsString()) {
return THROW_BAD_ARGS;
}
String::Utf8Value a(args[0]->ToString());
@bnsh
bnsh / moments.pl
Created September 3, 2011 18:13
Trevor's moments.awk in perl
#! /usr/bin/perl -w
use strict;
{
my @accs;
while (<STDIN>) {
chomp;
my ($val) = $_;
my ($val2, $val3, $val4);
@bnsh
bnsh / forehtesh.py
Last active June 20, 2016 08:22
My (proposed) solution to Ehtesh's problem
#! /usr/bin/python
import re
def main():
pairs = {}
threshold = 50 # change this to 50 for your actual problem
# From https://gist.github.com/shurane/80061efaadcf5bb7f56e
with open("Artist_lists_small.txt", "r") as fp:
for line in fp:

Keybase proof

I hereby claim:

  • I am bnsh on github.
  • I am binesh (https://keybase.io/binesh) on keybase.
  • I have a public key whose fingerprint is 421D B4C2 2E96 B8EE 7190 A0CF B42F E71C 7FC3 AD96

To claim this, I am signing this object:

#! /usr/local/torch/install/bin/th
require "cutorch"
--[=[
Can someone tell me why running this as
"th bernoullidemo.lua" works fine:
torch.DoubleTensor
torch.DoubleTensor
1 1 0 1 0 0 1 1 0 1
#! /usr/local/torch/install/bin/th
require "nn"
function multiselector(t)
local rv = nn.ConcatTable()
for i, k in ipairs(t) do
rv:add(nn.SelectTable(k))
end
return rv
#! /usr/local/torch/install/bin/th
-- Just a demonstration of how to use nn.ClassNLLCriterion.
require "nn"
local num_inputs = 10
local num_features = 5
local num_classes = 4
-- My horrendous version of random_patches. Is there a better way?
-- It takes as input a ByteTensor(batchsz, 3, x, y) and
-- outputs a DoubleTensor(batchsz, 3, 224, 224) which will be random
-- 224x224 patches sampled from the input. (And, it rescales it from
-- {0,255} to {-1,1})
local function random_patches(images, patchx, patchy)
-- So, images dimension should be n x channels x szx x szy
local n, channels, szx, szy = unpack(images:size():totable())
local rv = torch.zeros(n, channels, patchx, patchy)
#! /usr/local/torch/install/bin/th
-- This will take as arguments a program and
-- exec it, and pipe into the program.. I dunno.
-- Let's say "Howdy"
-- For example: th pipedemo.lua /bin/cat
-- will simply echo "Howdy!" to the console
-- But, th pipedemo.lua /usr/bin/md5sum says
-- 7105f32280940271293ee00ac97da5a7 -
#! /usr/local/torch/install/bin/th
local posix = require "posix"
local unistd = require "posix.unistd"
local stdio = require "posix.stdio"
local sys_wait = require "posix.sys.wait"
-- This will take as arguments a program and
-- exec it, and pipe into the program.. I dunno.
-- Let's say "Howdy"