Skip to content

Instantly share code, notes, and snippets.

View yangchi's full-sized avatar
🥟

Yang Chi yangchi

🥟
View GitHub Profile
from contextlib import contextmanager
import os
_FILE = "/tmp/temp_file.txt"
class MyClass:
def __init__(self, name):
self.name = name
print(f"MyClass instance '{self.name}' created.")
@yangchi
yangchi / keepass2-deps
Created December 27, 2013 03:11
Deps for KeepassX 2
sudo yum install qt-devel libgcrypt libgcrypt-devel
@yangchi
yangchi / java-config.sh
Created October 14, 2013 03:03
java config after install official JDK
sudo alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 20000
sudo alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 20000
sudo alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/jre/lib/i386/libnpjp2.so 20000
sudo alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 20000
sudo alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 20000
@yangchi
yangchi / latex2pdf
Last active December 24, 2015 10:09
Compile latex + bibtex into pdf with correct reference (A latex compile, 1 bibtex compile, another 3 latex compile, and then one divpdf conversion)
filename=`echo $1|awk -F. '{print $1}'`
latex $filename
bibtex $filename
for ((i = 1; i<=3; i++)); do
latex $filename
done
dvipdfmx $filename
@yangchi
yangchi / fedora-firewall-hg
Created September 25, 2013 02:52
Config Fedora firewall to make hg go through
#the command to config Fedora firewalld service is firewall-cmd. It's super easy to use.
#Read "https://fedoraproject.org/wiki/FirewallD#Using_firewall-cmd" for details
#list default firewall zone
firewall-cmd --get-default-zone
#make hg go through, suppose hg use port 8000 and HTTP, and the default firewall zone is 'public'
sudo firewall-cmd --zone=public --add-port=8000/tcp
@yangchi
yangchi / .zshrc
Last active December 23, 2015 05:19
my growing (just started) .zshrc file
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Example aliases
@yangchi
yangchi / latex-essential-install.sh
Last active December 23, 2015 05:18
My LaTeX essentials
sudo yum install texlive-algorithmicx texlive-amsrefs texlive-metapost texlive-setspace
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
//Stop working:
rhc app remove-alias -a myAppName --alias www.mywebsite.com
rhc app remove-alias -a myAppName --alias mywebsite.com
rhc app add-alias -a myAppName --alias www.mywebsite.com
rhc app add-alias -a myAppName --alias mywebsite.com
//Add
rhc alias add