This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gzip import GzipFile | |
from wsgiref.headers import Headers | |
import re | |
import cStringIO as StringIO | |
# Precompile the regex to check for gzip headers | |
re_accepts_gzip = re.compile(r'\bgzip\b') | |
# Precompile the regex to split a comma delimitered string of Vary headers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gevent import monkey | |
monkey.patch_all() | |
import gevent.pool | |
import os | |
import random | |
import time | |
import datetime | |
from multiprocessing import Semaphore, Array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Suspense, useEffect, useState } from "react"; | |
import type { ReactElement } from "react"; | |
type Props = { | |
fallback: ReactElement; | |
children: () => ReactElement; | |
}; | |
/** | |
* Almost like a normal <Suspense> component, except that for server-side |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Decoder, object, string } from 'decoders'; | |
type Example = { | |
eg: string; | |
}; | |
const exampleDecoder: Decoder<Example> = object({ | |
eg: string | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Range = [number, number] | |
type Position = { | |
offset: number | |
line: number | |
column: number | |
} | |
export type Location = { | |
start: Position |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put the following in your ~/.config/fish/completions directory | |
complete --command codegen --no-files --arguments "(codegen -l)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://henrik.nyh.se/2008/12/git-dirty-prompt | |
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/ | |
# username@Machine ~/dev/dir[master]$ # clean working directory | |
# username@Machine ~/dev/dir[master*]$ # dirty working directory | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Theres a gevent pool of 4 greenlets. Jobs are spawned continuously, blocking | |
until a free greenlet is available (default gevent.pool behaviour). Say, | |
a unit of work takes rougly a second. Then, at any moment, there are likely | |
4 jobs mid-execution. | |
The Goal | |
-------- | |
I want to catch both SIGINT/KeyboardInterrupt _and_ SIGTERM in | |
the main loop, and in a nondestructive way. By nondestructive, I mean (1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Alt 1: very explicit, but requires knowledge on what type of workers exist | |
from rq.workers.gevent import GeventWorker | |
w = GeventWorker(4) | |
# Alt 2: A bit like an "Abstract Factory", no need for knowing the implementing | |
# class names, backward compatible, and kind='forking' by default | |
from rq import Worker | |
w = Worker(4, kind='gevent') | |
# Alt 3: I don't think (2) works without really nasty tricks. This one is as |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[submodule "vim/bundle/vim-characterize"] | |
path = vim/pack/nvie/start/vim-characterize | |
url = https://github.com/tpope/vim-characterize.git |
NewerOlder