Skip to content

Instantly share code, notes, and snippets.

View samuelcolvin's full-sized avatar

Samuel Colvin samuelcolvin

View GitHub Profile
@samuelcolvin
samuelcolvin / cmongo.c
Created November 15, 2013 18:30
csv printer extension for python
#ifdef PYTHON
#include <Python.h>
#endif
#include "cmongo.h"
typedef int (*debug_func)(const char *, ...);
#define BLOCK 20000000
struct BigStr {
size_t buffer_size;
@samuelcolvin
samuelcolvin / TutorCruncher gource.sh
Created April 12, 2016 14:56
creating version history video of TutorCruncher
# to create the initial video, you need to press U twice once the video has started to force user names
gource -1920x1080 -o - --seconds-per-day 0.01 --hide progress,filenames | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 TutorCruncher.mp4
# to convert it to webm and make it a resonable size
ffmpeg -i TutorCruncher.mp4 -codec:v libvpx -b:v 3600k -an TutorCruncher.webm
@samuelcolvin
samuelcolvin / asyncio_queue.py
Last active May 1, 2016 16:43
Asyncio concurrency
import asyncio
q = asyncio.Queue()
async def produce():
for i in range(10):
await q.put(i)
@samuelcolvin
samuelcolvin / useharrier.py
Last active May 4, 2016 14:28
see samuelcolvin/harrier this should one day be a package of its own
import json
from time import time
import urllib.request
class UseHarrierError(Exception):
pass
class UseHarrierKeyError(KeyError):
import os
import signal
from fnmatch import fnmatch
from multiprocessing import Process
from pathlib import Path
from datetime import datetime
import pyinotify as ino

Static site generator inspired by jekyll but much improved

Features:

  • jinja templating language
  • written in python: easy to install modify and extend
  • built in redirects, sitemap and html checking.
  • support for resusable templates, allow reference to templates dir. or list of dirs, thereby allowing just a single file to be overruled.
  • auto-reload with dev. server
  • dynamic static file names to work well with CDNs
  • support for markdown and/or restructured text
#!/usr/bin/env sh
echo "Setting up strider and docker"
set -e
set -x
sudo apt-get update -y > /dev/null
sudo apt-get install -y mongodb curl git vim curl
[
{
"featureType": "landscape",
"elementType": "all",
"stylers": [
{
"hue": "#FFBB00"
},
{
"saturation": 43.4
@samuelcolvin
samuelcolvin / 623.py
Last active September 20, 2016 20:56
import re
import sys
from pathlib import Path
REGEXES = [(re.compile(p, f), r) for p, r, f in [
(r'^#(?: -\*-) coding: ?utf-8(?: -\*-)\n', '', 0),
(r"\.(encode|decode)\('utf-?8'\)", r'.\1()', 0),
('(class \w+)\(object\):\n', r'\1:\n', 0),
('super\(\w+, \w+\)\.', 'super().', 0),
('u"""(.*?)"""', r'"""\1"""', re.S),
#!/usr/bin/env python
"""
Open helpmanual.io man pages
Samuel Colvin 2016
"""
import json
import platform
import subprocess
import shlex
import sys