Skip to content

Instantly share code, notes, and snippets.

@critiqjo
critiqjo / PKGBUILD
Last active March 25, 2017 07:22
kaldi PKGBUILD (optional cuda build)
# Maintainer: Jingbei Li <i@jingbei.lli>
pkgname='kaldi'
pkgdesc='Speech recognition research toolkit'
pkgver=5.1.r7282.0d0316b48
pkgrel=1
makedepends=('gcc5' 'git' 'wget' 'subversion')
depends=('python2' 'openblas-lapack')
arch=('x86_64' 'i686')
url='https://github.com/kaldi-asr/kaldi'
license=('APACHE')
set smoothscroll
set noautofocus
let hintcharacters = "arstdwfpxcv"
let barposition = "bottom"
let langmap = "kj,jh,hk,KJ,JH,HK"
let blacklists = ["https://mail.google.com/*", "*://mail.google.com/*", "@https://mail.google.com/mail/*"]
unmap E R gR cr gy my mr gF zr gj
@critiqjo
critiqjo / alert.sh
Created October 18, 2016 17:22
A dumb timer-notifier!
#!/bin/bash
# Alerts a message using `notify-send` at the time specified.
# The time specified should be understood by `date -d` option.
set -e
[ -z "$2" ] && {
echo "Usage: $0 <time-desc> <message>"
echo
#!/bin/env python2
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('PangoCairo', '1.0')
from gi.repository import Gtk, GLib, Pango, PangoCairo
from datetime import datetime
class DigitalClock(Gtk.DrawingArea):
def __init__(self):
@critiqjo
critiqjo / memorder.rs
Last active August 29, 2016 07:40
Memory Ordering
use std::cell::UnsafeCell;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Barrier};
use std::thread;
struct UsizePair {
atom: AtomicUsize,
norm: UnsafeCell<usize>,
}
@critiqjo
critiqjo / bb_csv2json.py
Created May 11, 2016 10:33
Backblaze dataset parsing
#!/bin/python
import csv
import json
import sys
def key_proc(key):
return {
'smart_1_raw': '001R_read_err_rate',
'smart_1_normalized': '001N_read_err_rate',
@critiqjo
critiqjo / gif-cast.sh
Created January 9, 2016 21:09
Creating a gif screencast
#!/bin/bash
# Requirements:
# * xwininfo
# * recordmydesktop
# * mplayer
# * imagemagick
if [ -z "$1" ]; then
echo "Usage: $0 <gif-file>"
@critiqjo
critiqjo / pkgrecdep.sh
Created January 9, 2016 20:25
Pacman recursive dependency list
#!/bin/bash
total=( $1 )
len0=0
len1=${#total[*]}
while [ $len0 -ne $len1 ]; do
len0=$len1
t1=( "${total[@]}" )
t2=( `pacman -Qi "${t1[@]}" 2>/dev/null | \
sed -n 's/Depends On.*: \(.*\)$/\1/p'` )
@critiqjo
critiqjo / client.rs
Last active August 10, 2021 15:26
Buffered Client-Server
fn main() {
let mut ifx = Ifx::new("localhost:8080");
for i in 0..20 {
ifx.send(i);
}
}
use std::fmt::Display;
use std::io::{BufRead, BufReader, Lines, Write};
use std::net::TcpStream;
@critiqjo
critiqjo / col_print.py
Created June 16, 2015 07:50
Python: Multi-column printing of a list of strings
def col_print(lines, term_width=80, indent=0, pad=2):
n_lines = len(lines)
if n_lines == 0:
return
col_width = max(len(line) for line in lines)
n_cols = int((term_width + pad - indent)/(col_width + pad))
n_cols = min(n_lines, max(1, n_cols))
col_len = int(n_lines/n_cols) + (0 if n_lines % n_cols == 0 else 1)