Skip to content

Instantly share code, notes, and snippets.

View charlesreid1's full-sized avatar

Chaz Reid charlesreid1

View GitHub Profile
@charlesreid1
charlesreid1 / pims_pip_output
Last active November 13, 2017 19:58
Comparing simple test
(testenv) root@ae3529a7c667:/# python pimstest.py
(testenv) root@ae3529a7c667:/#
@charlesreid1
charlesreid1 / pubwatcher.py
Created November 28, 2017 12:48 — forked from minrk/pubwatcher.py
Watch IOPub traffic from IPython engines
import os
import sys
import json
import zmq
from IPython.zmq.session import Session
from IPython.parallel.util import disambiguate_url
from IPython.utils.path import get_ipython_dir
def main(connection_file):
# order list alphanumerically
# test with "bespin" theme only for now
# add others when things are working
# see https://github.com/chriskempson/base16-schemes-source/blob/master/list.yaml
#
unclaimed: https://github.com/chriskempson/base16-unclaimed-schemes
N=10000;
d=1e-6; %Diameter of particle
mu=1e-3; %viscosity of water
T=293; %temprature
KB=1.38e-23; %Boltzman const
pi=3.1415;
% drag Coeff -strength of random force exerting on particl
g=3*pi*mu*d; %Drag coef
disp (g);
tt=1000; % Maximum time
@charlesreid1
charlesreid1 / conditional_list_construction.py
Created December 16, 2017 16:45
Conditional list construction with booleans in Python
doit = True
dontdoit = False
print( doit*[1,2,3] + [4,5,6] + dontdoit*[7,8,9])
# prints [1, 2, 3, 4, 5, 6]
@charlesreid1
charlesreid1 / brain_transplant.py
Last active January 4, 2018 05:24
Give a Python class a brain transplant by modifying __class___.
class Foo(object):
def whoami(self):
self.foowuz = 666
print("I'm Foo, foo!")
class Bar(object):
def whoami(self):
self.barwuz = 777
print("I'm Bar, sucka!")
@charlesreid1
charlesreid1 / retry_function.py
Created December 16, 2017 16:51
If at first you don't succeed... try, try again!
def retry(func):
maxretries = 10
def wrapper(*args, **kwargs):
for i in range(maxretries, 0, -1):
try:
print('RETRY %d'%(i))
return func(*args, **kwargs)
except (Exception,)[:i - 1]:
pass
@charlesreid1
charlesreid1 / rubiks_revenge.py
Last active January 1, 2018 07:44
Script to test if a Rubiks Revenge cube has a cross on the side.
# Uses this rubiks cube solver:
# https://github.com/dwalton76/rubiks-cube-NxNxN-solver
from rubikscubennnsolver.RubiksCube444 import RubiksCube444, solved_4x4x4
from pprint import pprint
def get_cube():
"""
Get a 4x4 Rubiks Cube.
"""
order = 'URFDLB'
@charlesreid1
charlesreid1 / Bash Killswitch.md
Last active January 28, 2018 18:02
Bash implementation of a killswitch to check that backups are up-to-date.

Bash Killswitch

This is a bash implementation of a killswitch, which will monitor some action and raise an alert when the action fails or stops being performed.

This particular implementation runs an hourly backup script, and runs the killswitch daily at 4 AM to raise an alert if backups from the previous 24 hours failed.

@charlesreid1
charlesreid1 / _service.md
Created February 4, 2018 02:41 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)