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"""
def bulk_upsert(model, fields, values, by): | |
""" | |
Return the tuple of (inserted, updated) ids | |
""" | |
result = (None, None) | |
if values: | |
stmt = """ | |
WITH data_set AS ( | |
INSERT INTO %s (%s) |
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: |
#!/usr/bin/env python3 | |
""" | |
To run: python3 nb2to3.py notebook-or-directory | |
""" | |
# Authors: Thomas Kluyver, Fernando Perez | |
# See: https://gist.github.com/takluyver/c8839593c615bb2f6e80 | |
import argparse | |
import pathlib | |
from nbformat import read, write |
implementing user authentication with bcrypt in ChicagoBoss.
see http://shanelogsdon.com/erlang/implementing-user-authentication-with-bcrypt-in-chicagoboss
//PhantomJS http://phantomjs.org/ based web crawler Anton Ivanov anton.al.ivanov@gmail.com 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 = {}; | |
}; | |