Skip to content

Instantly share code, notes, and snippets.

View ergoithz's full-sized avatar
🚚
Moved to gitlab.com/ergoithz

Felipe A. Hernandez ergoithz

🚚
Moved to gitlab.com/ergoithz
View GitHub Profile
@ergoithz
ergoithz / utf8char.py
Last active January 2, 2016 19:09
How to read utf-8 char from file descriptor. Including doctest and algorithm used for range detection in main docstring.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def write_utf8_char(fd, char):
fd.write(unichr(char).encode("utf-8"))
def read_utf8_char(fd):
'''
>>> import os
@ergoithz
ergoithz / wacom-driver-installer
Last active January 3, 2016 18:49
Latest wacom driver installer, with rc.local patching for detecting new kernel versions, gksudo if display is available, and kernel-version aware.
#!/bin/bash
URL="http://downloads.sourceforge.net/project/linuxwacom/xf86-input-wacom/input-wacom/input-wacom-0.20.0.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Flinuxwacom%2Ffiles%2Fxf86-input-wacom%2Finput-wacom%2F&ts=`date +%s`&use_mirror=freefr"
WORKDIR="/tmp/wacom"
TARFILE="$WORKDIR/wacom.tar.bz2"
SRCDIR="$WORKDIR/input-wacom-*"
SCRIPT=`readlink -e $0`
NAME=`basename $SCRIPT`
@ergoithz
ergoithz / attribute.py
Created February 10, 2014 08:51
attribute decorator from wheezy.core
class attribute(object):
""" ``attribute`` decorator is intended to promote a
function call to object attribute. This means the
function is called once and replaced with
returned value.
>>> class A:
... def __init__(self):
... self.counter = 0
... @attribute
@ergoithz
ergoithz / index.html
Last active August 29, 2015 13:56
Micro AJAX snipped with hashbang urls (for browser history) with zero dependencies. Converts every link with 'ajax' class into a ajax link (for gracefully degrading) and only loads data from selected tags (section#content or body) into #content (for ajax using static files).
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Example</title>
<script src="uajax.js"></script>
</head>
<body>
<nav>
<ul>
@ergoithz
ergoithz / humbledup.py
Last active August 29, 2015 14:00
Humble Bundle duplicate finder
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import lxml, lxml.etree as etree
import collections
import urllib2
import pprint
import logging
import cPickle
@ergoithz
ergoithz / haxeCopy.sh
Created May 5, 2014 09:51
Clone haxe distribution
#!/bin/bash
tar -czf haxe.`haxe -version 2>&1`.tgz /usr/lib/haxe \
/usr/lib/neko \
/usr/lib/libneko.so \
/usr/bin/neko \
/usr/bin/nekoc \
/usr/bin/nekotools \
/usr/bin/haxe \
/usr/bin/haxedoc \
@ergoithz
ergoithz / hex.js
Created May 6, 2014 11:05
Simpler JS hex serialization
/* Damn simple hex parser, with utf8 convenience functions */
var utf8={
decode: function(s){
return decodeURIComponent(escape(s));
},
encode: function(s){
return unescape(encodeURIComponent(s));
}
},
hex={
@ergoithz
ergoithz / ec_3820t.py
Last active August 29, 2015 14:03
Simple ec script for controlling GPU and CPU fans for acer 3820T/3820TG/3820TZ/3820TGZ laptops
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
CONTROL_AUTO = 0x04
CONTROL_MANUAL = 0x14
FAN_MAX = 0x00
FAN_MIN = 0xFF
READY_TO_WRITE = 0x02
READY_TO_READ = 0x01
@ergoithz
ergoithz / ec2.py
Last active August 29, 2015 14:03
More sophisticated 3820TG EC tool
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
==== NOTES ====
```
3820TG LAYOUT
@ergoithz
ergoithz / create_venv.sh
Last active August 29, 2015 14:03
python3 venv on ubuntu
#!/usr/bin/env bash
#
# Usage create_venv.sh MYENV
#
# As Ubuntu guys loves patch things they shouldn't and break everything,
# python3 developers using their awful distro must to follow the
# following steps in order to use venv instead of simply executing
# 'python -m venv env'.
#
# Thanks, Canonical QA team deserves a big shiny medal.