Skip to content

Instantly share code, notes, and snippets.

View kootenpv's full-sized avatar

Pascal van Kooten kootenpv

  • Van Kooten AI Solutions / ex-mgnr
  • Utrecht, Netherlands
View GitHub Profile
@erikbern
erikbern / use_pfx_with_requests.py
Last active April 24, 2024 13:48
How to use a .pfx file with Python requests – also works with .p12 files
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 February 27, 2024 10:15
Minimal Working example of Elasticsearch scrolling using Python client
# 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 July 2, 2012 01:10
My new, simpler offlineimap configuration
# -*- 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
#
@timmyomahony
timmyomahony / nginx.conf
Created June 26, 2011 13:29
Python, UWSGI, Supervisor & Nginx
upstream uwsgi {
ip_hash;
server 127.0.0.1:40000;
}
server {
listen 80;
server_name www.domain.com;
root /sites/mysite/;
access_log /sites/mysite/log/nginx/access.log;
@mooz
mooz / .dir-locals.el
Created December 18, 2011 15:04
My flymake settings for C/C++
;; just an example
((c++-mode . ((flymake-additional-compilation-flags . ("-I../" "-std=c++0x")))))
@juanpabloaj
juanpabloaj / README.md
Last active June 18, 2018 13:02
Total of pip packages downloaded, separated by Python versions

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

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__)
#!/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 July 10, 2017 23:53
/src Makefile-generating-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
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;