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 / str2bf.py
Created January 1, 2012 08:32
String to brainfuck converter
#!/usr/bin/env python
# coding: utf-8
"""
String to Brainfuck.
Converts a string to a brainfuck code that prints that string.
Author: j0hn <j0hn.com.ar@gmail.com>
"""
@j0hn
j0hn / pre-commit
Created August 9, 2012 18:19
git pre commit hook to ask the user if he ran the tests
#!/bin/sh
# file .git/hooks/pre-commit
exec < /dev/tty
read -p "Did you run the tests? [yN]: " yn
case $yn in
[Yy]* ) echo "Ok, your good to go";;
* ) echo "What are you waiting for then?" && exit 1;;
esac
@j0hn
j0hn / faces.py
Created January 7, 2013 19:09
Face classification using SimpleAI
#!/usr/bin/env python
# coding: utf-8
import os
import math
import random
from PIL import Image
from simpleai.machine_learning import ClassificationProblem, is_attribute, NaiveBayes, precision, KNearestNeighbors
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
@j0hn
j0hn / game_walk.py
Last active December 11, 2015 17:58
A* algorithm applied to a game map
#!/usr/bin/env python
# coding: utf-8
import math
from simpleai.search import SearchProblem, astar
MAP = """
##############################
# # # #
# #### ######## # #
@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.
# Variables
set $mod Mod4
# Colors
set $base00 #101218
set $base01 #1f222d
set $base02 #252936
set $base03 #7780a1
set $base04 #C0C5CE
set $base05 #d1d4e0
# github.com/rafi i3status config
# i3status configuration file
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!