Skip to content

Instantly share code, notes, and snippets.

Avatar

James Bowler JamesKBowler

  • Data Centauri Ltd
  • Cheshire UK
View GitHub Profile
@gatopeich
gatopeich / install_Jupyter.sh
Last active Aug 9, 2020
Install Jupyter iPython Notebook on Android via Termux
View install_Jupyter.sh
pkg upgrade
# Install runtime deps
pkg install python libzmq libcrypt
# Add build deps
pkg install python-dev libzmq-dev libcrypt-dev clang
pip3 install -U pip
pip3 install pyzmq --install-option="--zmq=/usr/lib"
pip3 install jupyter
@ximeg
ximeg / ThresholdingAlgo.py
Created Apr 20, 2017
Python implementation of smoothed z-score algorithm from http://stackoverflow.com/a/22640362/6029703
View ThresholdingAlgo.py
#!/usr/bin/env python
# Implementation of algorithm from http://stackoverflow.com/a/22640362/6029703
import numpy as np
import pylab
def thresholding_algo(y, lag, threshold, influence):
signals = np.zeros(len(y))
filteredY = np.array(y)
avgFilter = [0]*len(y)
stdFilter = [0]*len(y)
anonymous
anonymous / gist:8564133
Created Jan 22, 2014
Print view of large pandas DataFrame. Modified from bigbug: http://stackoverflow.com/a/15786557/28035
View gist:8564133
import pandas
def _sw(df, up_rows=10, down_rows=5, left_cols=4, right_cols=3, return_df=False):
''' display df data at four corners
A,B (up_pt)
C,D (down_pt)
parameters : up_rows=10, down_rows=5, left_cols=4, right_cols=3
usage:
df = pd.DataFrame(np.random.randn(20,10), columns=list('ABCDEFGHIJKLMN')[0:10])
df.sw(5,2,3,2)
@davfre
davfre / git_cheat-sheet.md
Last active Sep 23, 2020
git commandline cheat-sheet
View git_cheat-sheet.md
@EyalAr
EyalAr / client.py
Created Dec 11, 2013
Demo code for my post about python's blocking stream reading functions.
View client.py
from subprocess import Popen, PIPE
from time import sleep
# run the shell as a subprocess:
p = Popen(['python', 'shell.py'],
stdin = PIPE, stdout = PIPE, stderr = PIPE, shell = False)
# issue command:
p.stdin.write('command\n')
# let the shell output the result:
sleep(0.1)
@kirpit
kirpit / bash.py
Last active Aug 31, 2020
Enables to run subprocess commands in a different thread with TIMEOUT option!
View bash.py
#! /usr/bin/env python
import threading
import subprocess
import traceback
import shlex
class Command(object):
"""
Enables to run subprocess commands in a different thread with TIMEOUT option.
@brantfaircloth
brantfaircloth / mult_prod_single_consume.py
Created Oct 1, 2011
Python multiprocessing: multiple producers, single consumer
View mult_prod_single_consume.py
import time
import random
from multiprocessing import Process, Queue, JoinableQueue, cpu_count
""" Adjust time.sleep() values to see action of consumer """
def work(id, jobs, result):
while True:
task = jobs.get()
if task is None:
You can’t perform that action at this time.