Skip to content

Instantly share code, notes, and snippets.

Avatar

Pascal van Kooten kootenpv

  • Van Kooten AI Solutions / MGNR.io
  • Utrecht, Netherlands
View GitHub Profile
View optional_args_decorator.py
def optional_arg_decorator(fn):
"""
wrap a decorator so that it can optionally take args/kwargs
when decorating a func
"""
# http://stackoverflow.com/a/32292739/2156113
@wraps(fn)
def wrapped_decorator(*args, **kwargs):
is_bound_method = args and hasattr(args[0], fn.__name__)
View unix_domain_client.py
#!/usr/bin/env python3
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version π, September 2017
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@dutc
dutc / Makefile
Last active Jul 10, 2017
/src Makefile-generating-Makefile
View Makefile
include meta.mk
include concrete.mk
CODE_TARGETS = postgresql-9.5.3 \
nginx-1.11.1 \
node-v6.2.1
$(foreach x,$(CODE_TARGETS),$(eval $(call META_TARGET,build/$x,.build-artefacts/$x,code/$x)))
BASE_PYTHON = 3.6.1
BUILD_FEATURES = dev
@ines
ines / emoji.py
Last active Mar 19, 2017
Use emoji name for spaCy models in v1.7 🦄
View emoji.py
import spacy
nlp = spacy.load('🦄')
doc = nlp(u'Wow, my model is named 🦄 !')
for word in doc:
print(word.text, word.tag_, word.dep_, word.head.text)
@juanpabloaj
juanpabloaj / README.md
Last active Jun 18, 2018
Total of pip packages downloaded, separated by Python versions
View README.md

Total of pip packages downloaded separated by Python versions

From June 26, 2016 (python 3.5.2 release) to Aug. 31, 2016.

Python versions from 2.6 to 3.5

downloads_by_versions

Without 2.7

View itmap.sol
library itmap {
struct entry {
// Equal to the index of the key of this item in keys, plus 1.
uint keyIndex;
uint value;
}
struct itmap {
mapping(uint => entry) data;
uint[] keys;
@erikbern
erikbern / use_pfx_with_requests.py
Last active Oct 18, 2021
How to use a .pfx file with Python requests – also works with .p12 files
View use_pfx_with_requests.py
import contextlib
import OpenSSL.crypto
import os
import requests
import ssl
import tempfile
@contextlib.contextmanager
def pfx_to_pem(pfx_path, pfx_password):
''' Decrypts the .pfx file to be used with requests. '''
@drorata
drorata / gist:146ce50807d16fd4a6aa
Last active Oct 12, 2021
Minimal Working example of Elasticsearch scrolling using Python client
View gist:146ce50807d16fd4a6aa
# Initialize the scroll
page = es.search(
index = 'yourIndex',
doc_type = 'yourType',
scroll = '2m',
search_type = 'scan',
size = 1000,
body = {
# Your query's body
})
@dabrahams
dabrahams / gist:3030332
Created Jul 2, 2012
My new, simpler offlineimap configuration
View gist:3030332
# -*- mode: conf; -*-
#
# NOTE: Settings generally support python interpolation. This means
# values can contain python format strings which refer to other values
# in the same section, or values in a special DEFAULT section. This
# allows you for example to use common settings for multiple accounts:
#
# [Repository Gmail1]
# trashfolder: %(gmailtrashfolder)s
#
@mooz
mooz / .dir-locals.el
Created Dec 18, 2011
My flymake settings for C/C++
View .dir-locals.el
;; just an example
((c++-mode . ((flymake-additional-compilation-flags . ("-I../" "-std=c++0x")))))