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 / login.py
Created October 4, 2011 03:13
GTK unittest example
#!/usr/bin/env python
# coding: utf-8
import gtk
class LoginWindow(gtk.Window):
def __init__(self):
gtk.Window.__init__(self)
self.connect("destroy", gtk.main_quit)
@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>
"""
import os
from functools import lru_cache
import requests
import urllib.parse
from flask import Flask
from flask import request
from flask import flash
from flask import url_for
#!/bin/bash
# Dependencies: imagemagick, i3lock-color-git, scrot
# IMAGE=$(mktemp).png
# scrot $IMAGE
# # convert $IMAGE -level 0%,100%,0.6 -filter Gaussian -resize 30% -define filter:sigma=2.5 -resize 333.33% $IMAGE
# convert -scale 10% -scale 1000% $IMAGE $IMAGE
# i3lock -i $IMAGE
# rm $IMAGE
# 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!
# Variables
set $mod Mod4
# Colors
set $base00 #101218
set $base01 #1f222d
set $base02 #252936
set $base03 #7780a1
set $base04 #C0C5CE
set $base05 #d1d4e0
@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 / 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 / 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 / hbuto.py
Created October 10, 2011 14:37
j0hn's hamster buto
#!/usr/bin/env python
# coding: utf-8
"""
j0hn's hamster buto.
Math bitches (?)
"""
import gtk