This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Problema: | |
module Foo | |
@hello = 42 | |
class Bar | |
# Desde acá quiero llegar a @hello. | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'irb/completion' | |
require 'wirble' | |
IRB.conf[:AUTO_INDENT] = true | |
IRB.conf[:USE_READLINE] = true | |
Wirble.init | |
Wirble.colorize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat <<EOF | sudo tee /usr/bin/jsonindent > /dev/null | |
#!/usr/bin/env python | |
import sys | |
import json | |
json.dump(json.load(sys.stdin), sys.stdout, indent=1) | |
sys.stdout.write('\n') | |
EOF | |
sudo chmod 0755 /usr/bin/jsonindent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check wether the given ``answer`` produces the right output for | |
* the current level. | |
* | |
* Returns ``null`` on success. Otherwise returns the wrong output. | |
*/ | |
Soret.check_answer = function(regex, repl) { | |
var user_output = Soret.sub(regex, repl); | |
if (user_output != Soret.get_expected_output()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf8 -*- | |
import re | |
import sys | |
import json | |
import logging | |
import random | |
from pprint import pprint | |
from django.db.models import ObjectDoesNotExist | |
from django.db.models import Q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
_HERE_DIR = os.path.dirname(os.path.abspath(__file__)) | |
_ROOT_DIR = os.path.join(_HERE_DIR, '..') | |
BOT_NAME = 'mscrap' | |
BOT_VERSION = '1.0' | |
SPIDER_MODULES = ['mscrap.spiders'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(MSCRAP)k@del ~/q/mscrap_git/mscrap/mscrap % cat exporters.py | |
# -*- coding: utf8 -*- | |
from scrapy.contrib.exporter import JsonLinesItemExporter | |
class TypedJsonLinesItemExporter(JsonLinesItemExporter): | |
""" | |
Like JsonLinesItemExporter but each line adds the item type. |