Skip to content

Instantly share code, notes, and snippets.

--- PKGBUILD 2011-12-17 19:24:25.000000000 -0300
+++ PKGBUILD.new 2012-01-01 14:33:41.501639783 -0300
@@ -22,3 +22,3 @@
source=("http://us.download.nvidia.com/XFree86/Linux-${_arch}/${pkgver}/${_pkg}.run")
- md5sums=('29e47c0ba2d755a0807661a988af0773')
+ md5sums=('5a80b13f0e92e33367d49866f6377dc1')
fi
@k0001
k0001 / peuler.hs
Created December 31, 2011 16:09
Project Euler solutions in Haskell
import Control.Applicative
--
-- Utils
--
-- Ordered List: difference
minus :: (Ord a) => [a] -> [a] -> [a]
minus (x:xs) (y:ys) = case (compare x y) of
LT -> x : minus xs (y:ys)
@k0001
k0001 / crawler.py
Created August 15, 2011 00:52 — forked from jmoiron/crawler.py
Simple gevent/httplib2 web crawler.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Simple async crawler/callback queue based on gevent."""
import traceback
import logging
import httplib2
import gevent
@k0001
k0001 / microformats.py
Created May 4, 2011 11:48 — forked from scoffey/microformats.py
Python microformats parser that supports hCard, hCalendar, hResume and rel-tag and provides an extensible model for other microformats.
# -*- coding: utf-8 -*-
#!/usr/bin/env python
"""
Model for microformat properties and parsers. A microformat parser can
parse an HTML element into a dictionary of properties, whose keys are
strings and whose values are strings or other dictionary of properties.
As an example, the main program of this script parses an hResume from
given URL.
@k0001
k0001 / gist:833226
Created February 18, 2011 03:50
Some *sh file redirection
k@del 0 /tmp % { echo "a" > /dev/stdout; echo "b" > /dev/stderr } 1> >(tee -a out) 2> >(tee -a err >&2)
b
a
k@del 0 /tmp % cat out
a
k@del 0 /tmp % cat err
b
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font">
<test name="family">
<string>Monaco</string>
</test>
<edit name="autohint" mode="assign">
<bool>true</bool>
</edit>
#!/usr/bin/env python
# coding: utf-8
# Copyright (c) 2011, Renzo Carbonara <[email protected]>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
#!/usr/bin/env python
# coding: utf-8
# Copyright (c) 2010, Renzo Carbonara <[email protected]>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
headers.update({ # Vertical alignment pleases my mind.
'acta_num' : int(d['acta_num']),
'ult_mod_ver' : int(d['ult_mod_ver']) # WTF is this?
'mayoria_base' : un(d['mayoria_base']).lower(),
'mayoria_tipo' : un(d['mayoria_tipo']).lower(),
'miembros_total' : int(d['miembros_total']),
'presidente_apellido' : d['presidente_apellido'].title(),
'presidente_nombre' : d['presidente_nombre'].title(),
'quorum_tipo' : un(d['quorum_tipo']),
'resultado' : VOTE_RESULTS[d['resultado']] })
In [313]: rx = r'(.*?), *(.*?[%(uni_az)s])([%(uni_AZ)s].*?[%(uni_az)s](?=[%(uni_AZ)s]))(.*)' % {
.....: 'uni_AZ': u"A-ZÑÀÁÄÂÉÈËÊÍÌÏÎÓÒÖÔÚÙÜÛ",
.....: 'uni_az': u"a-zñàáäâéèëêíìïîóòöôúùüû" }
In [314]: w = u'FOO, Bar BaSomewhere ÖverÉloh Rainbow'
In [315]: re.match(rx, w).groups()
Out[315]: (u'FOO', u'Bar Ba', u'Somewhere \xd6ver', u'\xc9loh Rainbow')