Skip to content

Instantly share code, notes, and snippets.

View huangruizhe's full-sized avatar

huangruizhe

View GitHub Profile
@pzelasko
pzelasko / install_k2.sh
Last active February 25, 2022 05:40
Steps needed to install K2 from scratch
#!/usr/bin/env bash
# Common steps
conda create -n k2 python=3.8
conda activate k2
conda install -c nvidia cudnn=7.6.5 cudatoolkit=10.2
conda install -c pytorch pytorch torchaudio
pip install cmake
mkdir build
pushd build
@HarshTrivedi
HarshTrivedi / pad_packed_demo.py
Last active March 2, 2024 16:49 — forked from Tushar-N/pad_packed_demo.py
Minimal tutorial on packing (pack_padded_sequence) and unpacking (pad_packed_sequence) sequences in pytorch.
import torch
from torch import LongTensor
from torch.nn import Embedding, LSTM
from torch.autograd import Variable
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
## We want to run LSTM on a batch of 3 character sequences ['long_str', 'tiny', 'medium']
#
# Step 1: Construct Vocabulary
# Step 2: Load indexed data (list of instances, where each instance is list of character indices)
@alainrafiki
alainrafiki / compress_s3_images.py
Created February 8, 2016 00:58 — forked from rigoneri/compress_s3_images.py
Simple python code to compress (jpeg/png) images uploaded to S3. In this use case I want to compress down all images that are over 500 KB down to 80% quality which brings the images down to about 100KB. Feel free to muck with the values.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from boto.s3.connection import S3Connection
from cStringIO import StringIO
from PIL import Image as pil
AWS_KEY = '[AWS KEY HERE]'
@squarism
squarism / iterm2.md
Last active May 1, 2024 15:40
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@rigoneri
rigoneri / compress_s3_images.py
Created February 5, 2013 19:26
Simple python code to compress (jpeg/png) images uploaded to S3. In this use case I want to compress down all images that are over 500 KB down to 80% quality which brings the images down to about 100KB. Feel free to muck with the values.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from boto.s3.connection import S3Connection
from cStringIO import StringIO
from PIL import Image as pil
AWS_KEY = '[AWS KEY HERE]'
@fzero
fzero / 1 tmux.conf
Last active February 7, 2024 15:00
Some tmux configurations, scripts and aliases I use.
# I prefer ctrl-a - helps when dealing with machines that only have Screen
unbind C-b
set -g prefix C-a
# Making windows purrty
set-window-option -g status-bg cyan
set-window-option -g status-fg black
set-window-option -g window-status-current-bg black
set-window-option -g window-status-current-fg white
@spicycode
spicycode / tmux.conf
Created September 20, 2011 16:43
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@myusuf3
myusuf3 / uninstall.sh
Created April 21, 2011 03:06
how to cleanly uninstall python packages installed with python setup.py
# Next time you need to install something with python setup.py -- which should be never but things happen.
python setup.py install --record files.txt
# This will cause all the installed files to be printed to that directory.
# Then when you want to uninstall it simply run; be careful with the 'sudo'
cat files.txt | xargs sudo rm -rf