Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import numpy as np
from random import shuffle
from scipy.stats import beta
def randAvg(values, target_mean, n, a=None, b=None):
n = int(n)
values = sorted(list(values))
#!/usr/bin/env perl
# define the mapping from Mathematica vars to python vars
$r1 = "MIX_RATE";
$r2 = "FADE_RATE";
$s = "SCALE";
$u1 = "last_signal";
$u2 = "NOISE_FLOOR";
$y = "ss_old";
$v = "v_old";
#!/bin/bash
NAME="code-print"
USAGE="code-print - uses LaTeX and pygments to
format source code as a PDF
code-print [options] filename [filename]
options:
#!/usr/bin/env bash
NAME="img2pdf"
USAGE="$NAME - uses LaTeX to place images full-page
and convert to PDF. Useful for printing.
$NAME [options] filename [filename]
options:
import numpy as np
import matplotlib as mpl
mpl.use('pgf')
def figsize(scale):
fig_width_pt = 469.755 # Get this from LaTeX using \the\textwidth
inches_per_pt = 1.0/72.27 # Convert pt to inch
golden_mean = (np.sqrt(5.0)-1.0)/2.0 # Aesthetic ratio (you could change this)
fig_width = fig_width_pt*inches_per_pt*scale # width in inches
fig_height = fig_width*golden_mean # height in inches
import numpy as np
import matplotlib as mpl
mpl.use('pgf')
def figsize(scale):
fig_width_pt = 469.755 # Get this from LaTeX using \the\textwidth
inches_per_pt = 1.0/72.27 # Convert pt to inch
golden_mean = (np.sqrt(5.0)-1.0)/2.0 # Aesthetic ratio (you could change this)
fig_width = fig_width_pt*inches_per_pt*scale # width in inches
fig_height = fig_width*golden_mean # height in inches
import olap.xmla.xmla as xmla
provider = xmla.XMLAProvider()
con = provider.connect(location='http://{server}/OLAP/msmdpump.dll'.format(server='YOUR SERVER IP'))
# Verify that we are connected
print c.getMDSchemaCubes()
# Write MDX query
cmd = """SELECT NON EMPTY { [Measures].[Count] } ON COLUMNS FROM [OLAP]"""
cur = con.Execute(cmd)
#!/usr/bin/env bash
TRACKPOINT_NAME="DualPoint Stick"
TRACKPAD_NAME="AlpsPS/2 ALPS GlidePoint"
POLL_INTERVAL=1.0s
point_xid=$(xinput --list --id-only "$TRACKPOINT_NAME")
pad_xid=$(xinput --list --id-only "$TRACKPAD_NAME")
is_enabled() {
#!/usr/bin/env bash
TRACKPOINT_NAME="DualPoint Stick"
TRACKPAD_NAME="AlpsPS/2 ALPS GlidePoint"
POLL_INTERVAL=1.0s
point_xid=$(xinput --list --id-only "$TRACKPOINT_NAME")
pad_xid=$(xinput --list --id-only "$TRACKPAD_NAME")
is_enabled() {