Skip to content

Instantly share code, notes, and snippets.

@vznncv
vznncv / paramiko_sftp_large_file_downloading_demo.py
Created January 18, 2020 09:26
Workaround to download a large file with paramiko from a sftp server
"""
The script contains example of the paramiko usage for large file downloading.
It implements :func:`download` with limited number of concurrent requests to server, whereas
paramiko implementation of the :meth:`paramiko.SFTPClient.getfo` send read requests without
limitations, that can cause problems if large file is being downloaded.
"""
import logging
import os
package main
// Here's a half-assed "jepsen" test for nsq_to_file that exercises its
// management of files in -work-dir and -output-dir in the face of multiple
// processes sharing those directories.
//
// Usage:
//
// 1. Ensure that the versions of nsqd & nsq_to_file you intend to test are on
// your $PATH:
@colmmacc
colmmacc / shardcalc.py
Last active July 22, 2024 19:52
Calculate the blast radius of a shuffle shard
import sys
# choose() is the same as computing the number of combinations. Normally this is
# equal to:
#
# factorial(N) / (factorial(m) * factorial(N - m))
#
# but this is very slow to run and requires a deep stack (without tail
# recursion).
#
@Jaza
Jaza / Private-pypi-howto
Last active July 2, 2023 16:24
Guide for how to create a (minimal) private PyPI repo, just using Apache with directory autoindex, and pip with an extra index URL.
*
@jehiah
jehiah / nsq_testing.go
Last active June 30, 2020 08:13
NSQ Producer testing abstraction
package nsqutils
import (
"sync"
"time"
nsq "github.com/nsqio/go-nsq"
)
// Producer is an interface that nsq.Producer fulfills
@lewisd32
lewisd32 / iptableflip.sh
Created April 15, 2015 18:20
Snippet of Unbounce script for restarting HAProxy with zero downtime
echo "Flipping tables! (╯°□°)╯︵ ┻━┻"
num_rules=3
real=3 # exposed to the ELB as port 443
test=4 # used to install test certs for domain verification
health=5 # used by the ELB healthcheck
blue_prefix=855
green_prefix=866
@lukechampine
lukechampine / a.c
Created October 19, 2014 01:00
a.c (with a.h expanded)
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<sys/mman.h>
typedef void V;typedef int I;typedef double F;typedef unsigned char C,*S;typedef long L;
#define O printf
#define R return
#define I(a...) if(a)
#define W(a...) while(a)
@schlamar
schlamar / gioloop.py
Last active November 30, 2017 09:55
Tornado IOLoop implementation with gobject/gtk.
import datetime
import functools
import logging
import os
import time
import gobject
import gtk
@rofl0r
rofl0r / init.c
Created August 6, 2013 21:15
minimal init daemon by rich felker, author of musl libc
#define _XOPEN_SOURCE 700
#include <signal.h>
#include <unistd.h>
int main()
{
sigset_t set;
int status;
if (getpid() != 1) return 1;
@mccutchen
mccutchen / bound_methods.py
Created October 18, 2012 14:26
bound_methods.py
import random
import types
# Two ways to create "bound" methods from plain functions
def bind(instance, f):
"""Bind function f to the given instance."""
return lambda *args, **kwargs: f(instance, *args, **kwargs)
def make_method(instance, f):