Skip to content

Instantly share code, notes, and snippets.

import datetime
from matplotlib import dates as mpl_dates
import matplotlib.font_manager
from pylab import figure
import scipy.ndimage.filters as filters
fontfamily = ["Arial"]
dpi = 200.0
package main
import (
"crypto/sha256"
"flag"
"fmt"
"runtime"
"time"
)
# $Id: screenrc,v 1.15 2003/10/08 11:39:03 zal Exp $
#
# /etc/screenrc
#
# This is the system wide screenrc.
#
# You can use this file to change the default behavior of screen system wide
# or copy it to ~/.screenrc and use it as a starting point for your own
# settings.
#
#!/usr/bin/env python
import numpy as np
import sys
FRAME_SIZE = 1920*1080*3
BPC = 2
MAXINT = (256**BPC) - 1
GAMMA = 2.0 # A much faster approximation than 2.2
import numpy as np
import scipy.linalg as linalg
import scipy.optimize as optimize
# r0: rate constant for initial partition -> active partition
# r1: rate constant for active partition -> inactive partition
# rate_constant = np.log(2)/half_life
def single_compound_matrix(r0, r1):
return np.array([[-r0, r0, 0], [0, -r1, r1], [0, 0, 0]]).T
randomly
@crowsonkb
crowsonkb / WorldClock.js
Created October 25, 2014 02:28
Patched version of OS X 10.10 World Clock dashboard widget to include UTC
/*
Copyright _ 2005, Apple Computer, Inc. All rights reserved.
NOTE: Use of this source code is subject to the terms of the Software
License Agreement for Mac OS X, which accompanies the code. Your use
of this source code signifies your agreement to such license terms and
conditions. Except as expressly granted in the Software License Agreement
for Mac OS X, no other copyright, patent, or other intellectual property
license or right is granted, either expressly or by implication, by Apple.
*/
class Timer:
def __enter__(self):
self.__interval = None
self.__start = time.perf_counter()
return self
def __exit__(self, *args):
self.__end = time.perf_counter()
self.__interval = self.__end - self.__start
print(self.__interval, file=sys.stderr)
@crowsonkb
crowsonkb / timer.py
Created June 22, 2015 16:21
Timer context manager
import time
class Timer:
def __init__(self, times):
self.times = times
self.start = None
def __enter__(self):
self.start = time.perf_counter()
return self.start
@crowsonkb
crowsonkb / withlet.py
Last active August 29, 2015 14:26
A horrible context manager...
from contextlib import contextmanager
import sys
@contextmanager
def let(**kwargs):
to_del = []
to_set = {}
bindings = sys._getframe(2).f_locals
for k, v in kwargs.items():
if k in bindings: