Skip to content

Instantly share code, notes, and snippets.

View matagus's full-sized avatar
🐿️

Matías Agustín Méndez matagus

🐿️
View GitHub Profile
@matagus
matagus / paginator.html
Created November 5, 2010 01:58
django-haystack paginator
{% if paginator.count %}
<div class="pagination clearfix">
<span class="results-count">{{ paginator.count }} {% trans 'results' %}</span>
<span class="paginator">
{% if page.has_previous %}
<a title="previous page" class="prev awesome medium button"
href="?{{ search_qs }}&amp;page={{ page.previous_page_number }}&amp;{{ form.previous_facets_encoded }}">
&nbsp;
</a>
{% endif %}
@matagus
matagus / supervisord
Created January 10, 2011 12:26
supervisor /etc/init.d script
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
opts="${opts} "
pidfile="/var/run/supervisord/supervisord.pid"
fromcron="0"
# this next comment is important, don't remove it - it has to be somewhere in
# the init script to kill off a warning that doesn't apply to us
@matagus
matagus / do_tweepy.py
Created January 19, 2011 22:31
using tweepy
>>> import tweepy
>>> auth = tweepy.BasicAuthHandler("matagus", "blablabla")
>>> api = tweepy.API(auth)
>>> user = tweepy.api.get_user('twitter')
>>> user
<tweepy.models.User object at 0xb767b88c>
>>> user.id_str
u'783214'
>>> user = tweepy.api.get_user('matagus')
>>> user.id_str
@matagus
matagus / webworker-pool.js
Created January 30, 2011 16:55
A pool of webworkers
// From: https://gist.github.com/605541#file_js_web_worker_pool.js
// Web Worker Pool
// size is the max number of arguments
function WorkerPool(size) {
var workers = 0,
jobs = [];
// url: the url of the worker script
// msg: the initial message to pass to the worker
// cb : the callback to recieve messages from postMessage.
@matagus
matagus / table_to_array.js
Created January 30, 2011 22:10
jQuery table to Array
var data = (function () {
var _data = [];
$("#<TABLE-ID-REPLACE-ME> tbody td").each(
function () {
var rowIndex = this.parentNode.rowIndex -1,
cellValue = this.innerHTML.trim();
if (_data[rowIndex]) {
_data[rowIndex].push(cellValue);
} else {
_data[rowIndex] = [cellValue];
"""
Copyright (c) 2009, Sean Creeley
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, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
@matagus
matagus / rabbitmq_publish.py
Created May 10, 2011 15:49
Publishing to a rabbitmq exchange using pika BlockingConnection
# -*- coding: UTF-8 -*-
from pika import PlainCredentials, ConnectionParameters, BasicProperties
from pika.adapters import BlockingConnection
from django.conf import settings
credentials = PlainCredentials(
settings.RABBIT["userid"], settings.RABBIT["password"])
parameters = ConnectionParameters(credentials=credentials,
@matagus
matagus / learning.hs
Created June 14, 2011 19:39
Learning Haskell
-- this a single line comment
--
{- and this
- is a multiline
- comment
- in haskell code -}
a = "my string"
b = ['m', 'y', 's', 't', 'i', 'n', 'g']
@matagus
matagus / dict.xml
Created July 4, 2011 00:32
processing xml with namespaces with python
<?xml version="1.0" encoding="UTF-8"?>
<hen:logs xmlns:hen="http://www.site.de/schemas/logs/1.0">
<!--<hen:vhost>
<hen:uuid></hen:uuid>
</hen:vhost>-->
<hen:vhost>www.site1.de
<hen:uuid>c5328180-e52b-4af5-bf6e-7a9e7c1754e2</hen:uuid>
</hen:vhost>
<hen:vhost>www.site2.de
<hen:uuid>b7b968db-27c7-4430-8346-b2c6e2de8065</hen:uuid>
@matagus
matagus / django-exceptions-tracedump.txt
Created December 15, 2011 02:58
How to analyze rare exceptions in django/python projects by G. Dumpleton
from: http://groups.google.com/group/modwsgi/browse_thread/thread/f289c8167923aab7
The problem with Django is that there are certain circumstances where
it will hide the actual error message and traceback and replace it
will a higher level exception, but with the traceback then being where
that higher level exception was raised. This is one such case.
To try and find the real location of the exception add the following
to your WSGI script file.