Skip to content

Instantly share code, notes, and snippets.

View sirkonst's full-sized avatar

Konstantin vz'One Enchant sirkonst

View GitHub Profile
@sirkonst
sirkonst / shell.nix
Last active October 6, 2022 08:19
Nix shell environment for development python project (with virtualenv and IPython support)
with import <nixpkgs> { };
let
pythonPackages = python37Packages;
pythonVenvDir = ".local/${pythonPackages.python.name}";
envPackages = [
gettext
gitMinimal
];
preInstallPypiPackages = [
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@BlakeGardner
BlakeGardner / compact.js
Last active February 19, 2024 16:55
Compact all collections inside of a MongoDB database
// This script loops though the list of collection names in a MongoDB and runs the compact operation on them
// Simply paste this into the Mongo shell
use testDbName;
db.getCollectionNames().forEach(function (collectionName) {
print('Compacting: ' + collectionName);
db.runCommand({ compact: collectionName });
});
@NicolasT
NicolasT / nonblocking.py
Last active February 11, 2024 19:15
Using the 'splice' syscall from Python, in this demonstration to transfer the output of some process to a client through a socket, using zero-copy transfers. See 'splice.py'. Usage: 'python splice.py' in one console, then e.g. 'nc localhost 9009' in another. 'nonblocking.py' is a demonstration of using 'splice' with non-blocking IO.
'''
Demonstration of using `splice` with non-blocking IO
Lots of code is similar to 'splice.py', take a look at that module for more
documentation.
'''
import os
import os.path
import errno
@dropwhile
dropwhile / gist:2556514
Created April 30, 2012 08:19
socketpool memcache example
# -*- coding: utf-8 -
#
import logging
import random
import memcache
import gevent.socket
# monkey patch to patch sockets
memcache.socket = gevent.socket
from socketpool.pool import ConnectionPool, MaxTriesError