Skip to content

Instantly share code, notes, and snippets.

@ybv
ybv / keybase_proof.md
Created October 5, 2017 11:00
Keybase proof

Keybase proof

I hereby claim:

  • I am ybv on github.
  • I am ybv (https://keybase.io/ybv) on keybase.
  • I have a public key whose fingerprint is 73E1 C42C 843E 57CD 3E17 D31E E799 7AB7 8F04 7A32

To claim this, I am signing this object:

This file has been truncated, but you can view the full file.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
@ybv
ybv / misc
Last active August 29, 2015 14:07
'''
python roundup
131 -> 200
999 -> 1000
'''
def roundUp(num):
val = (int(str(num)[0])+1)*pow(10,len(str(num))-1)
'''
python sqrt
@ybv
ybv / gist:c976cda4798641c93d3c
Created October 15, 2014 23:32
Simple Bloom Filter api with Tornado.
import os
import hashlib
import tornado.ioloop
import tornado.web
from tornado import gen
class bv(object):
def __init__(self):
self.bit_vector = None
@ybv
ybv / gist:441e7b42841edb3f3551
Created October 10, 2014 13:18
pymongo query builder for '$or' & '$and' with lists, dicts and conditions
{'$or': [ {'$and':[ dict(zip(keys, triple.split(':')))] } if '0' not in triple else {'$and':[ dict(zip(keys, triple.split(':')[:2]))] } for triple in termstr ]}
### Keybase proof
I hereby claim:
* I am ybv on github.
* I am ybv (https://keybase.io/ybv) on keybase.
* I have a public key whose fingerprint is 6F18 8E89 D9FF 0DEA 6DDC EBE3 4A22 C131 8406 61A2
To claim this, I am signing this object:
@ybv
ybv / gist:10013075
Last active August 29, 2015 13:58
Reverse soundex match. Trying to cut short each word in a given sentence till the extent that it shares the same soundex with the actual word. Totally naive and needs fixes.
import string
import fuzzy
import itertools
import random
import re
from itertools import groupby
table = string.maketrans("","")
soundex = fuzzy.Soundex(4)
dmetaphone = fuzzy.DMetaphone(4)
@ybv
ybv / gist:8140873
Created December 27, 2013 00:44
A script to move folders containing .mp3 files to user's own music folder. Often, downloaded music on my mac rests in downloads, thought this would be handy to move all of them at once.
#!/usr/bin/nv bash
directory=$PWD
dot="."
ddot=".."
myarray=(`find $directory -type f -name "*.mp3"`)
if [ ${#myarray[@]} -gt 0 ]; then
for name in ${myarray[@]}; do
if [[ "$(dirname $name)" != "$dot" ]]; then
rsync -aq --progress $(dirname $name) "/Users/ybv/music"
fi