Skip to content

Instantly share code, notes, and snippets.

View j0hn's full-sized avatar

Gonzalo Garcia Berrotaran j0hn

  • Cordoba, Argentina
View GitHub Profile
@j0hn
j0hn / svm.py
Created August 1, 2014 18:02
s0plete vector machines
# -*- coding: utf-8 -*-
import numpy
import cvxopt
cvxopt.solvers.options['show_progress'] = False
class SVMClassifier(object):
@j0hn
j0hn / preprocess.py
Created March 3, 2015 20:28
Parallel processing on iepy
"""
Corpus preprocessing script
Usage:
preprocess.py
preprocess.py [<modulo> <modulo_result>] [options]
preprocess.py --increment-ner
preprocess.py -h | --help | --version
Options:
#!/bin/bash
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: scancan.sh <number of scans> <preparation time>"
exit
fi
echo "Waiting $2"
sleep $2
@j0hn
j0hn / changobot.py
Created July 22, 2015 14:20
Bot de cadenas de markov
# -*- coding: utf-8 -*-
import markovify
import codecs
# Get raw text as string.
with codecs.open("corpus.txt", encoding="utf-8") as f:
text = f.read()
# Build the model.
#/usr/bin/env python
# -*- encoding: utf-8 -*-
import time
import random
import sys
if len(sys.argv) > 1:
word = " ".join(sys.argv[1:])
else:
@j0hn
j0hn / criba.py
Created March 14, 2011 11:59
Prime criba
#!/usr/bin/env python
import sys
import time
def f(k):
return lambda j: (j <= k) or (j%k != 0)
def criba(i, version=1):
p = range(2, i)
@j0hn
j0hn / loading_bar.py
Created May 10, 2011 12:34
Loading bar
#!/usr/bin/env python
# encoding: utf-8
import os
import sys
import fcntl
import struct
import termios
import threading
from time import sleep
@j0hn
j0hn / adding_a_method.py
Created June 1, 2011 01:03
How to add a method to an object's instance
#!/usr/bin/env python
# coding: utf-8
"""
Shows how to add a method to a instance of an object.
"""
class Useless:
"""
Does nothing, unless you hack it.
@j0hn
j0hn / screenshoter
Created July 11, 2011 00:53
Takes a screenshot and uploads it to imgur
#!/bin/bash
IMGPATH="/tmp/$(date +%s)_imgur.png"
if [ "$1" = "window" ]; then
scrot --focused "$IMGPATH"
else
scrot "$IMGPATH"
fi
@j0hn
j0hn / checkouts.py
Created August 17, 2011 23:39
Checkout models
#!/usr/bin/env python
# coding: utf-8
"""
Checkout queue test, a test between two models of queues on supermarkets
and banks and stuff like that.
The two models tested are:
Independent checkouts Single queue