Skip to content

Instantly share code, notes, and snippets.

@kentwait
kentwait / python_pool_processes.ipynb
Last active October 28, 2015 07:20
How to use a pool of processes to speed up analysis in Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kentwait
kentwait / docker_cmd_tricks.md
Last active February 23, 2017 09:44
Docker command tricks

Remove ALL containers

docker rm -f $(docker ps -a -q)

Remove ALL images

docker rmi $(docker images -q)

Remove dangling docker images

docker images -qf dangling=true | xargs docker rmi

Bind docker.sock to access docker commands from inside a container

@kentwait
kentwait / genetic_code.py
Last active March 9, 2018 06:56
Genetic code
GENETIC_CODE = {
'AAA': 'K',
'AAC': 'N',
'AAG': 'K',
'AAT': 'N',
'ACA': 'T',
'ACC': 'T',
'ACG': 'T',
'ACT': 'T',
'AGA': 'R',
@kentwait
kentwait / network_summary_stats.ipynb
Last active June 12, 2018 20:47
Understanding networks through descriptive statistics
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# 1. What will the following code print out?
x = 0
if x > 10:
print(True)
else:
print(False)
# 2. Refer to the following function
def f(a, b=0):
if 0 in a:
def fibo_r(x):
if x <= 2:
return 1
return fibo_r(x-1) + fibo_r(x-2)
def fibo_l(x):
l = [0, 1, 1]
if x <= 2:
return 1
for i in range(3, x):
# Add .asoundrc file
Copied from https://gist.github.com/AfzalivE/54214bf437ca1775b5b8e7934cc137db
```
# ps3 eye + 3.5mm speaker Raspberry Pi
## Suggested by http://julius.sourceforge.jp/forum/viewtopic.php?f=9&t=66
## Modified by https://github.com/afzalive
pcm.jack {
type hw
card ALSA
def carrier_square_wave_generator(gpio, frequency, signal_length):
"""
Generate carrier square wave.
"""
waveform = []
# frequency is number of cycles per second, usually 38 kHz
micro_per_cycle = 1000.0 / frequency # 1 / kHz is millisecond, * 1000 is microsecond
# number of cycles during the signal
# signal_length is in microseconds
num_cycles = int(round(signal_length / micro_per_cycle))
@kentwait
kentwait / hdf5_h5py_install.md
Last active June 11, 2021 14:25
Install HDF5 and h5py supporting MPI (Parallel HDF5)

How to install HDF5 and h5py supporting MPI on OS X

Works on Mac OS 10.11.6, HDF5 1.8.17

HDF5

  1. Download and install dependencies like zlib, openmpi. Use homebrew.
  2. Download source tarball from http://www.hdfgroup.org/HDF5/release/obtain5.html
  3. Configure Makefile using the following command:
$ CC=/usr/local/bin/mpicc ./configure --with-zlib=/usr/local/opt --disable-fortran --prefix=/usr/local/ --enable-shared --enable-parallel

HOWTO init a ReactJS-Tauri app in Mac OS

The following instructions have worked for me running Mac OS 11.4.0 X64 with Node.js 16.4.0, Rust 1.53 and Tauri 1.0.0-beta.4.

Init a ReactJS app using npm

First, cd to parent directory where the root directory of the app will be located, ie: /home/me/src. Use the following command to generate the react directory structure: