Skip to content

Instantly share code, notes, and snippets.

View armonge's full-sized avatar
🏠

Andrés Reyes Monge armonge

🏠
View GitHub Profile
@armonge
armonge / whois.py
Last active December 15, 2015 23:09
Simple whois server
import os
import sqlite3 as sqlite
import socket
HOST = ''
PORT = 1043
BUFSIZE = 1024
ADDR = (HOST,PORT)
WORKDIR = '/home/armonge/tmp/whois-python/'
@armonge
armonge / .gtkrc-2.0
Created October 18, 2012 02:44
Monospaced fonts in pidgin
style "imhtml-fix"
{
font_name = "Monospace 8"
}
# Conversation entry box--where you type.
widget "*pidgin_conv_entry" style "imhtml-fix"
# Conversation history pane--where you read the conversation.
widget "*pidgin_conv_imhtml" style "imhtml-fix"
from suds.client import Client
year = 2012
month = 10
client = Client('https://servicios.bcn.gob.ni/Tc_Servicio/ServicioTC.asmx?WSDL')
for data in client.service.RecuperaTC_Mes(year,month)[0][0]:
print u'{fecha}: {valor}'.format(fecha=data['Fecha'], valor=data['Valor'])
@armonge
armonge / gist:2830057
Created May 29, 2012 19:04
django youtube field
import urlparse
import re
from django.db import models
from django import forms
def validate_youtube_url(value):
'''El patron lo saque de http://stackoverflow.com/questions/2964678/jquery-youtube-url-validation-with-regex'''
pattern = r'^http:\/\/(?:www\.)?youtube.com\/watch\?(?=.*v=\w+)(?:\S+)?$'
@armonge
armonge / video_list.py
Created March 15, 2012 00:16
Get a list of all the youtube download URL's for PyCon2012
from bs4 import BeautifulSoup
from urlparse import parse_qs, urlparse
from urlparse import unquote, urlparse, parse_qs
from concurrent.futures import ProcessPoolExecutor
import urllib
import sys
video_list = []
sys.setrecursionlimit(10000)
@armonge
armonge / admin.py
Created January 13, 2012 04:13
Show an image in django admin list_display, using sorl-thumbnail
class ProductAdmin(admin.ModelAdmin):
list_display = ('name','thumb')
def thumb(self, obj):
return render_to_string('thumb.html',{
'image': obj.image
})
thumb.allow_tags = True
@armonge
armonge / urls.py
Created November 10, 2011 20:56 — forked from mhulse/urls.py
Django: How to upgrade this old functional view to new class based view?
###### NEW:
from django.conf.urls.defaults import *
from sporty import views
urlpatterns = patterns('',
url(
# 30 characters or fewer. Letters, numbers and @/./+/-/_ characters:
r'^users/(?P<username>[a-zA-Z0-9@.+-_]+)/$',
@armonge
armonge / Questions
Created September 6, 2011 00:49
GOTO Amsterdam
Day job: Web Developer
What is your language of choice: Python
Open Source contributions: No biggies here, just some patch in https://github.com/mozes/smpp.pdu
How do you use GitHub: Mostly i work for organizations that provide me some git repos here, but i also mantain some gists and template django projects i use regularly
@armonge
armonge / gist:1163934
Created August 22, 2011 23:43 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
Day job: Web Developer in Nicaragua
Favorite Python project: Django
Favorite Conference: Haven't attended any yet :(
Python Experience Level: Intermediate
@armonge
armonge / mixins.py
Created August 22, 2011 16:35
A model Mixin to use in translatable applications, to use inherit your models from this
class TranslatableModelMixin(models.Model):
'''
Adapted from http://snippets.dzone.com/posts/show/2979
'''
language = models.CharField(max_length=2, choices=settings.LANGUAGES, db_index=True)
translation_of = models.ForeignKey(
to='self',
related_name='translation_set',
limit_choices_to={'language' : settings.DEFAULT_LANGUAGE},
blank=True,