Skip to content

Instantly share code, notes, and snippets.

@alhoo
alhoo / dualboot encrypted ubuntu 18.04.md
Created July 25, 2018 08:42
Installing ubuntu 18.04 alongside windows

Preparations in windows

  • Shrink windows to free up some space for the ubuntu installation

Installing ubuntu 18.04

  • boot from the live-cd
  • create partitions for the luks storage and /boot
  • cryptsetup a new luks partition
  • launch disks
@alhoo
alhoo / audio_predict.py
Last active February 1, 2019 15:58
Predict next audio frame
"""
!pip install matplotlib scipy numpy keras python_speech_features
"""
import scipy
import scipy.io.wavfile
from python_speech_features import mfcc
from matplotlib import pyplot as plt
import numpy as np
from keras.layers import Dense, Input, CuDNNLSTM, TimeDistributed
#!/usr/bin/env bash
N=30
DRYRUN=false
WORKDIR=/home/lasse/Desktop
HISTORY=__HISTORY
HISTORY_DIR=$WORKDIR/$HISTORY/$(date +%Y%m%d)
if [ "$1" != "" ]; then N=$1; fi
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
%pylab inline
pylab.rcParams['figure.figsize'] = (20, 16)
from collections import Counter
from glob import glob
from datetime import datetime, timedelta
@alhoo
alhoo / backups
Last active April 21, 2019 10:15
$ cat bin/backups.sh
#!/usr/bin/env bash
# sudo apt-get install rdiff-backup
BACKUPS="$HOME/backups"
rdiff-backup --exclude $BACKUPS \
--exclude $HOME/VirtualBox\ VMs \
--exclude $HOME/Downloads \
$HOME $BACKUPS
@alhoo
alhoo / bashrc
Last active May 11, 2019 05:04
bashrc PS1
# support cd .....
cd () {
if [ $# -eq 1 ] && [ "${1:0:3}" == "..." ]; then
for ((i=1; i<=${#1} - 1; i++)); do
builtin cd ..;
done;
pwd;
else
builtin cd "$@"
fi
@alhoo
alhoo / zshrc
Last active June 28, 2019 11:00
function json_double_escape () {
printf '%s' "$1"|python -c 'import json,sys,re; print(re.subn(r"\\", r"\\\\", json.dumps(sys.stdin.read(), ensure_ascii=False))[0])'
}
function command_exec_handler() {
STARTTIME=$(date --iso-8601=seconds)
SECONDS=0
eval $1;
EXIT_VALUE="$?"
CMD=$(json_double_escape $1)
%%javascript
IPython.notebook.kernel.execute('nb_name = "' + IPython.notebook.notebook_name + '".replace(".ipynb", "")')
---
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; </style>"))
%matplotlib inline
from matplotlib import pyplot as plt
%pylab inline
import datetime
import json
def dateconverter(o):
if isinstance(o, datetime.datetime):
return o.__str__()
def json_dumps(data):
return json.dumps(data, default=dateconverter)
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="https://rawgit.com/lmcnulty4/d3dragSelector/master/dragSelector.js"></script>
<style>
.selector {
fill: blue;
fill-opacity: 0.3;
stroke: blue;