Skip to content

Instantly share code, notes, and snippets.

Working from home

Gustavo León Tramontin urkh

Working from home
View GitHub Profile
aisayko /
Last active Jul 12, 2021
Postgresql bulk upsert in Python (Django)
def bulk_upsert(model, fields, values, by):
Return the tuple of (inserted, updated) ids
result = (None, None)
if values:
stmt = """
WITH data_set AS (
awesomebytes /
Last active Nov 25, 2021
Make a function or method threaded in python with a decorator

How to make a python function or class method threaded

From this stack overflow question I got this great snippet.

# Threaded function snippet
def threaded(fn):
    """To use as decorator to make a function call threaded.
    Needs import
    from threading import Thread"""
from rest_framework.serializers import ModelSerializer
AVAILABLE_CONFIGS_FIELD = ('fields', 'read_only_fields', 'exclude', 'write_only_fields')
class BaseModelSerializer(ModelSerializer):
Clase abstracta serializadora donde se pueden configurar campos para cada acciones genéricas de
las vistas ModelViewSet que provee DjangoRestFramework y acciones personalizadas
Serializer Ex:
takluyver /
Last active Nov 5, 2021
Run 2to3 on IPython notebooks
#!/usr/bin/env python3
To run: python3 notebook-or-directory
# Authors: Thomas Kluyver, Fernando Perez
# See:
import argparse
import pathlib
from nbformat import read, write
slogsdon /
Last active Apr 2, 2016
Erlang: User authentication with bcrypt and ChicagoBoss
antivanov / webcrawler.js
Last active Dec 18, 2021
Simple PhantomJS-based web crawler library
View webcrawler.js
//PhantomJS based web crawler Anton Ivanov 2012
//UPDATE: This gist has been made into a Node.js module and now can be installed with "npm install js-crawler"
//the Node.js version does not use Phantom.JS, but the API available to the client is similar to the present gist
(function(host) {
function Crawler() {
this.visitedURLs = {};