Skip to content

Instantly share code, notes, and snippets.

View javierhonduco's full-sized avatar

Javier Honduvilla Coto javierhonduco

View GitHub Profile
@javierhonduco
javierhonduco / requests_retry_on_5xx.py
Created July 14, 2015 14:51
requests_retry_on_5xx.py
from requests.packages.urllib3.util import Retry
from requests.adapters import HTTPAdapter
from requests import Session
import requests
requests.packages.urllib3.disable_warnings()
MAX_RETRIES = 2
session = Session()
session.mount("http", HTTPAdapter(
import gc
from celery.signals import task_postrun
@task_postrun.connect
def gc_on_task_postrun(**kwargs):
gc.collect()
@javierhonduco
javierhonduco / locale.py
Last active August 29, 2015 14:26 — forked from alexissmirnov/locale.py
Django QueryParameterLocaleMiddleware
from django.middleware import locale
from django.utils import translation
class QueryParameterLocaleMiddleware(locale.LocaleMiddleware):
"""
Django's LocaleMiddleware picks the locale setting of the request from
multiple sources such as a cookie, Accept-Language header and server-side
session.
This middleware adds one more way to specify the language by supplying
@javierhonduco
javierhonduco / gist:2331576
Created April 7, 2012 19:38 — forked from jonnybeadle/gist:1989179
jQuery Google CDN
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>
Dota - Basshunter
Winston Churchill's Boy - Benjamin Clementine
El Mal - Los Punsetes
Life Less Frightening - Rise Against
For The Strangers - Suede
Suburban Home - Descendents
Life Eternal - Mayhem
Christmas (Baby Please Come Home) - Mariah Carey
Pistol (A. Cunanan, Miami, FL. 1996) - Modest Mouse
She’s In Fashion (Remastered) - Suede
@javierhonduco
javierhonduco / server.py
Created September 4, 2012 15:02
Just the flask server version of wonderful @mattt's https://github.com/mattt/GroundControl/ Just add a procfile and maybe gunicorn. Enjoy! ;)
from flask import Flask
from plistlib import writePlistToString
app = Flask(__name__)
@app.route("/")
def default_plist():
plist_content = {
'Greeting' : "Hello, World",
'Price' : 4.20,
'FeatureXIsLaunched' : True
@javierhonduco
javierhonduco / sort1mb.cpp
Created October 28, 2012 22:05 — forked from preshing/sort1mb.cpp
Sort one million 8-digit numbers in 1MB RAM
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef unsigned int u32;
typedef unsigned long long u64;
//-------------------------------------------------------------------------
// WorkArea
//-------------------------------------------------------------------------
@javierhonduco
javierhonduco / capuccino_blanco.rb
Created November 11, 2012 15:07
Receta de capuccino de/con chocolate blanco (dependiendo de las proporciones)
puts "Listo para ser completado!"
@javierhonduco
javierhonduco / helpers.uri.js
Created December 14, 2012 00:35
Url serialization helpers in javascript
(function () {
uri = {}; var response = "?";
uri.serialize = function(_params){
for(var _value in _params){
response += encodeURIComponent(_value);
response += "=";
response += encodeURIComponent(_params[_value]);
response += "&";
@javierhonduco
javierhonduco / gist:4392974
Created December 27, 2012 23:03
Some webpages gathered around
http://docs.python.org/2/library/os.html
http://pypi.python.org/pypi/colorama
http://fabric.readthedocs.org/en/0.9.0/usage/env.html
http://docs.fabfile.org/en/1.5/usage/parallel.html
http://docs.python.org/2/library/curses.html
http://stackoverflow.com/questions/2122385/dynamic-terminal-printing-with-python
http://stackoverflow.com/questions/1956777/how-to-make-fabric-ignore-offline-hosts-in-the-env-hosts-list
http://awaseconfigurations.wordpress.com/2011/10/20/fun-with-fabric-first-lab-tests/