Skip to content

Instantly share code, notes, and snippets.

class Noun(object):
def __call__(self):
pass
verb = Noun()
verb()
@copitux
copitux / wsse.py
Created February 25, 2013 13:42
Extend soap lib suds: UsernameToken with password digest
from base64 import b64encode
from suds.wsse import UsernameToken
try:
from haslib import sha1
except:
from sha import new as sha1
@copitux
copitux / High concurrency.md
Created April 8, 2013 07:53
[Spanish] High concurrency. Ando jugando con estas tecnologías y los conceptos pueden estar equivocados. Fork y corrige si ves algo raro sin dudarlo!

High concurrency

threading, multiprocessing, eventloop, coroutines, celery, twisted, gevent, libevent, eventlet, libev, epoll, select, kqueue, greenlet ...

Aquí el fin último es la asincronia, no bloquear la aplicación/ejecución y para ello nos apoyamos en la concurrencia y paralelismo. También conocido como asyncronous I/O

En aplicaciones web donde networking I/O está a la orden del día, sumado a alto rendimiento (x000 request/sec) soluciones como gevent se hacen necesarias.

Clasics

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@copitux
copitux / routers.py
Created June 13, 2013 07:15
App router to Django Rest Framework 2.3.5
from django.core.exceptions import ImproperlyConfigured
from django.db.models import get_app
from django.utils.importlib import import_module
from rest_framework.routers import DefaultRouter
from rest_framework.urlpatterns import format_suffix_patterns
class App(DefaultRouter):
"""
@copitux
copitux / filters.py
Last active July 14, 2025 16:55
Iso 8601 DateTimeFilter to Django Rest Framework and django-filter
"""
The MIT License (MIT)
Copyright (c) <2013> <David Medina>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@copitux
copitux / unite.ctrl-p.vim
Created September 4, 2013 08:41
unite.ctrl-p
" Ctrl-p behaviour {{{
nnoremap <Leader><Leader> :Unite -start-insert file_rec/async<CR>
call unite#filters#matcher_default#use(['matcher_fuzzy'])
call unite#filters#sorter_default#use(['sorter_reverse'])
call unite#custom#source('file_mru,file_rec,file_rec/async,grep,locate',
\ 'ignore_pattern', join(['\.git/', 'tmp/', 'bundle/'], '\|'))
let g:unite_prompt = '>>> '
let g:unite_winheight = 15
@copitux
copitux / datastructures.py
Last active December 23, 2015 04:48
DotNestedDict
class DotNestedDict(dict):
"""
Working with nested dicts (common with mongodb resources) in
a easy way
nested = DotNestedDict({
'lvl1': {'lvl2': {'lvl3': 'here'}},
'collection': [0, 1, 2, 3, {'nested': 4}],
})