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 / 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 / safe_date.py
Created August 18, 2014 05:58
Self-healing date function
import calendar
def a(year, month, day):
year += (month-1) // 12
month = (month-1) % 12 + 1
while day > calendar.monthrange(year, month)[1]:
day -= calendar.monthrange(year, month)[1]
year += month // 12
month = month % 12 + 1
@ergoithz
ergoithz / __init__.py
Created October 7, 2014 11:03
initial_data attribute support for django models (like a fixture but only once model is created)
# myproject/myapp/management/__init__.py
from django.db.models.signals import post_syncdb
import myapp.models
def post_syncdb_handler(sender, **kwargs):
'''
Handler will be called on every syncdb to set initial data for models if `initial_data` attr
is set.