Skip to content

Instantly share code, notes, and snippets.

import subprocess
def scatter_plot(x, y, title="line1", width=80, height=25):
gnuplot = subprocess.Popen(["/usr/bin/gnuplot"],
stdin=subprocess.PIPE)
gnuplot.stdin.write(("set term dumb %d %d\n"%(width, height)).encode('utf-8'))
gnuplot.stdin.write(("plot '-' using 1:2 title '%s' with linespoints \n" % (title)).encode('utf-8'))
for i,j in zip(x,y):
gnuplot.stdin.write(("%f %f\n" % (i,j)).encode('utf-8'))
gnuplot.stdin.write("e\n".encode('utf-8'))
gnuplot.stdin.flush()
import subprocess
def get_terminal_size():
import os
env = os.environ
def ioctl_GWINSZ(fd):
try:
import fcntl, termios, struct, os
cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ,
@emgram769
emgram769 / Makefile
Created December 9, 2015 03:19
zipline Makefile
STOCKS=$(shell cat portfolio.txt)
ALGODIR=algos
PERFDIR=perf
ALGOS=$(wildcard $(ALGODIR)/*.py)
PERFS=$(patsubst $(ALGODIR)/%.py,$(PERFDIR)/%.perf,$(ALGOS))
CAPITAL=1000
START_DATE=2011-1-1
END_DATE=2012-1-1
@emgram769
emgram769 / brailleplot.c
Created March 8, 2017 10:13
brailleplot
// gcc brailleplot.c -o brailleplot
// python -c "print('\n'.join(['{} {}'.format(i, i**2) for i in range(-20, 20)]))" |./brailleplot 30 30
#include <locale.h>
#include <wchar.h>
#include <stdlib.h>
wchar_t to_braille(unsigned char byte) {
return 10240 + (
((byte >> 7) & (1 << 0)) |
((byte >> 3) & (1 << 3)) |