Skip to content

Instantly share code, notes, and snippets.

View pombredanne's full-sized avatar

Philippe Ombredanne pombredanne

View GitHub Profile
# Fix keyboard interrupts when using multiprocessing.pool.imap().
# Usage:
# import fix_multiprocessing.py
from multiprocessing.pool import IMapIterator
def wrapper(func):
def wrap(self, timeout=None):
# Note: the timeout of 1 googol seconds introduces a rather subtle
@vsajip
vsajip / pyvenvex.py
Last active April 29, 2024 07:26
A script which demonstrates how to extend Python 3.3's EnvBuilder, by installing setuptools and pip in created venvs. This functionality is not provided as an integral part of Python 3.3 because, while setuptools and pip are very popular, they are third-party packages.The script needs Python 3.3 or later; invoke it using"python pyvenvex.py -h"fo…
#
# Copyright (C) 2013-2020 Vinay Sajip. New BSD License.
#
import os
import os.path
from subprocess import Popen, PIPE
import sys
from threading import Thread
from urllib.parse import urlparse
from urllib.request import urlretrieve
{% extends "admin/change_list.html" %}
{% load admin_list i18n mptt_admin %}
{% block result_list %}
{% mptt_result_list cl %}
{% endblock %}
#!/bin/sh
""":"
which python3 >/dev/null 2>&1 && exec python3 "$0" "$@"
which python >/dev/null 2>&1 && exec python "$0" "$@"
which python2 >/dev/null 2>&1 && exec python2 "$0" "$@"
echo "Error: configure wrapper requires python"
exec echo "Either install python, or use cmake directly"
":"""
@jart
jart / fastio.py
Created October 23, 2016 06:44
Multithreaded Python os.walk
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@EricDuminil
EricDuminil / trie.py
Last active December 31, 2023 06:04 — forked from atiking/regexp-trie.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
#author: rex
#blog: http://iregex.org
#filename trie.py
#created: 2010-08-01 20:24
#source uri: http://iregex.org/blog/trie-in-python.html
# escape bug fix by fcicq @ 2012.8.19
@jayvdb
jayvdb / missing-license-task.md
Last active December 29, 2021 19:53
Missing license GitHub task

Add a missing license to a repository

Three steps:

  1. Find a repository without a LICENSE or LICENSE.md file.
  2. Determine the most appropriate license for the repository.
  3. Create a pull request adding a LICENSE or LICENSE.md file.

@pombredanne
pombredanne / migrate-redis.py
Created December 20, 2019 16:09 — forked from thomasst/migrate-redis.py
Migrate Redis data on Amazon ElastiCache
"""
Copies all keys from the source Redis host to the destination Redis host.
Useful to migrate Redis instances where commands like SLAVEOF and MIGRATE are
restricted (e.g. on Amazon ElastiCache).
The script scans through the keyspace of the given database number and uses
a pipeline of DUMP and RESTORE commands to migrate the keys.
Requires Redis 2.8.0 or higher.
@AmitGupta7580
AmitGupta7580 / api.py
Created April 17, 2021 09:46
bulk_search API Code suggestion for vulnerablecode
from urllib.parse import unquote
from django.db.models import Q
from django.urls import reverse
from django_filters import rest_framework as filters
from drf_spectacular.utils import extend_schema, inline_serializer
from packageurl import PackageURL
from rest_framework import serializers, viewsets, mixins
from rest_framework.decorators import action