Skip to content

Instantly share code, notes, and snippets.

@k0001
k0001 / gist:653592
Created October 29, 2010 13:47
nginx config: userdir php.
location ~ ^/~(.+?)/(.+?\.php)$ {
root /home/$1/www/$2;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ ^/~(.+?)(/.*)?$ {
alias /home/$1/www$2;
}
@k0001
k0001 / gist:656921
Created October 31, 2010 18:06
.irbrc
require 'irb/completion'
require 'wirble'
IRB.conf[:AUTO_INDENT] = true
IRB.conf[:USE_READLINE] = true
Wirble.init
Wirble.colorize
$.ajax({
method: 'GET',
url: '/search.json',
data: 'q=' + escape(_mq_input.val()),
traditional: true,
dataType: 'json', // response's
complete: function(xhr, status) {
if (xhr.getResponseHeader('content-type') || '' == 'application/json')
var data = JSON.parse(xhr.responseText);
if ((status == 'success' || status == 'notmodified') && data['status'] == 'OK') {
# Problema:
module Foo
@hello = 42
class Bar
# Desde acá quiero llegar a @hello.
end
end
# NOTE: I have no reason for indenting this like I do.
# But writing scrappers can get boring sometimes, you know.
# -^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^
foo = un(first_or_value(tr.select('//*[preceding-sibling::font/a[contains(., "Bajar")]]')))
# -^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^
if 'nominal' in foo: l.add_value('tipo', 'nominal')
elif 'numerica' in foo: l.add_value('tipo', 'numerica')
else : raise ValueError(u'Not "nominal" nor "numerica" in %s' % foo)
# -^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^
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')
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']] })
#!/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,
#!/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,
<?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>