Skip to content

Instantly share code, notes, and snippets.

View rahimnathwani's full-sized avatar

Rahim Nathwani rahimnathwani

View GitHub Profile
# From https://xiaoxing.us/2018/09/04/creating_swap_on_lightsail/
# fallocate is instant; no point wasting time writing zeroes
sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo cp /etc/fstab /etc/fstab.bak
# Activate swap on boot
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
@rahimnathwani
rahimnathwani / setup.sh
Last active November 24, 2020 06:26 — forked from bradp/setup.sh
New Mac Setup Script
echo "Creating an SSH key for you..."
ssh-keygen -t rsa -b 2048
echo "Please add this public key to Github \n"
echo "https://github.com/account/ssh \n"
echo "and to virtual servers\n"
read -p "Press [Enter] key after this..."
echo "Installing xcode-stuff"
xcode-select --install
import random
donkey = 0
car = 10 # car is worth more than a donkey
prizes = [car, donkey, donkey] # there's always exactly one car
N = 1000000
def pick_a_door(prizes):
# wget https://github.com/xtaci/kcptun/releases/download/v20170525/kcptun-linux-amd64-20170525.tar.gz
# tar xvf kcptun-linux-amd64-20170525.tar.gz
mv server_linux_amd64 /usr/local/bin/kcptun_server
mv /usr/local/bin/server_linux_amd64 /usr/local/bin/kcptun_server
sudo mkdir -p /etc/kcptun
sudo bash -c "cat <<EOT > /etc/kcptun/server_conf.json
{
\"listen\": \":21\",
\"target\": \"127.0.0.1:20001\",
cd /usr/src/sn986
./sdk.unpack
cd /usr/src/sn986/snx_sdk/buildscript
make sn98660_QR_Scan_402mhz_sf_defconfig
cd /usr/src/sn986/snx_sdk/middleware
mkdir -p _install/lib _install/include;
cp video/middleware/lib/lib* rate_ctl/middleware/lib/lib* sdrecord/middleware/lib/lib* audio/middleware/lib/lib* _install/lib
cp -r video/middleware/include/snx_isp video/middleware/include/snx_vc rate_ctl/middleware/include/snx_rc sdrecord/middleware/include/snx_record audio/middleware/include/* _install/include
PATH=/usr/src/sn986/snx_sdk/toolchain/crosstool-4.5.2/bin:${PATH}
cd /usr/src/sn986/snx_sdk/app/example/src/ipc_func/rtsp_server
@rahimnathwani
rahimnathwani / install-gpu-gce.sh
Last active August 4, 2017 19:28
Set up a Google Cloud GPU instance for doing the exercises in course.fast.ai
#!/bin/bash
if ! dpkg-query -W cuda; then
curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
dpkg -i ./cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
fi
apt-get update
apt-get -y upgrade
apt-get -y install tmux build-essential gcc g++ make binutils software-properties-common cuda unzip
modprobe nvidia
nvidia-smi
@rahimnathwani
rahimnathwani / gce-create-from-snapshot.sh
Created March 20, 2017 12:11
Create GPU instance from previously-create snapshot
gcloud compute snapshots list
gcloud compute disks create deep-learning-persistent-disk-1 --size=25GB --source-snapshot=deep-learning-snapshot-1
gcloud beta compute instances create gpu-instance-1 \
--machine-type n1-standard-1 --zone asia-east1-a \
--accelerator type=nvidia-tesla-k80,count=1 \
--image-family ubuntu-1604-lts --image-project ubuntu-os-cloud \
--maintenance-policy TERMINATE --no-restart-on-failure \
--disk=auto-delete=yes,boot=yes,name=deep-learning-persistent-disk-1
gcloud compute instances add-tags gpu-instance-1 --tags https-server
@rahimnathwani
rahimnathwani / gce-create.sh
Created March 20, 2017 12:09
Create GPU instance on Google Cloud, for course.fast.ai
gcloud beta compute instances create gpu-instance-1 \
--machine-type n1-standard-1 --zone asia-east1-a \
--accelerator type=nvidia-tesla-k80,count=1 \
--image-family ubuntu-1604-lts --image-project ubuntu-os-cloud \
--maintenance-policy TERMINATE --no-restart-on-failure \
--boot-disk-size=25GB
@rahimnathwani
rahimnathwani / gist:57f1a5743566d85e9a4c
Last active October 12, 2015 04:31 — forked from andrewlkho/gist:23b5b5bcf853b3473421
How to install debian to a USB drive for use on a MacBook Air

This guide shows how to install debian so that it can be booted and run from a USB drive on a MacBook Air. I use this to store a copy of my PGP master keypair. Networking is deliberately not configured and all operations requiring the master keypair (such as signing other people's keys) are done only on this system. See the debian wiki for information on how to separate your key. Note that this is slightly different to using a live CD. It is not possible to tailor the base configuration of a live CD to one's own requirements, and they frequently automatically connect to the nearest local network. Nevertheless, if you wish to use a live CD instead, I recommend Tails. Arturo Filastò has written a similar guide for Tails.

The method I use requires [VirtualBox][4], which should also contain a working debian installation itself. An alternative method would be to use [debootstrap][5] b

from __future__ import division
from scikits.audiolab import flacread
from numpy.fft import rfft, irfft
from numpy import argmax, sqrt, mean, diff, log
from matplotlib.mlab import find
from scipy.signal import blackmanharris, fftconvolve
from time import time
import sys
from parabolic import parabolic