Skip to content

Instantly share code, notes, and snippets.

View laozhu's full-sized avatar
👨‍💻
Coding ideas

Ritchie Zhu laozhu

👨‍💻
Coding ideas
View GitHub Profile
@laozhu
laozhu / lsof.sh
Created October 30, 2014 06:01
列出nginx进程,包括主(master)进程和工作(worker)进程。
$ sudo lsof -nP -i | grep LISTEN
...
nginx 1330 root 6u IPv4 11055 0t0 TCP *:80 (LISTEN)
nginx 1331 www-data 6u IPv4 11055 0t0 TCP *:80 (LISTEN)
nginx 1332 www-data 6u IPv4 11055 0t0 TCP *:80 (LISTEN)
nginx 1333 www-data 6u IPv4 11055 0t0 TCP *:80 (LISTEN)
nginx 1334 www-data 6u IPv4 11055 0t0 TCP *:80 (LISTEN)
...
@laozhu
laozhu / dnscrypt-startup-script.sh
Last active March 18, 2016 05:41
dnscrypt startup script
description "dnscrypt startup script"
start on (local-filesystems and started dbus and stopped udevtrigger)
stop on runlevel [016]
script
exec /usr/local/sbin/dnscrypt-proxy --resolver-name=opendns --local-address=127.0.0.2 --user=dnscrypt --logfile=/var/log/dnscrypt.log --pidfile=/var/run/dnscrypt.pid
end script
@laozhu
laozhu / install-java.sh
Created August 29, 2014 04:02
Install Java SE on Ubuntu
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer oracle-java8-installer
sudo update-java-alternatives -s java-7-oracle
sudo update-java-alternatives -s java-8-oracle
sudo apt-get install oracle-java8-set-default
@laozhu
laozhu / preinstall-pillow.sh
Created April 28, 2014 12:42
before you install Pillow on ubuntu or debian
sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev
@laozhu
laozhu / unzip.sh
Last active March 18, 2016 05:41
解决 Linux 下面解压 .zip 文件乱码的问题。
unzip -O CP936 xxx.zip
@laozhu
laozhu / sync-vb-additions-version.sh
Created February 11, 2014 03:51
解决Virtualbox和Virtualbox Additions版本不同步问题
# install ruby for windows
# http://rubyinstaller.org/
$ gem sources --remove https://rubygems.org/
$ gem sources -a http://ruby.taobao.org/
$ gem sources -l
*** CURRENT SOURCES ***
http://ruby.taobao.org
@laozhu
laozhu / remove-ati-driver.sh
Created January 18, 2014 14:24
不慎安装ATI DRIVER失败,进不了桌面怎么处理
sudo sh /usr/share/ati/fglrx-uninstall.sh
sudo apt-get remove --purge fglrx*
sudo rm /etc/X11/xorg.conf
sudo dpkg-reconfigure xserver-xorg
sudo reboot
@laozhu
laozhu / datetimeformat.py
Last active January 2, 2016 09:49
How to custom datetime filter in Flask
# 第一种定义方式
@app.template_filter('datetimeformat')
def datetimeformat(value, format='%Y/%m/%d %H:%M'):
return value.strftime(format)
# 第二种定义方式
def datetimeformat(value, format='%Y/%m/%d %H:%M'):
return value.strftime(format)
app.jinja_env.filters['datetimeformat'] = datetimeformat
@laozhu
laozhu / logoutview.py
Created January 4, 2014 02:54
Class Based Logout View of Django
# -*- coding: utf-8 -*-
from django.core.urlresolvers import reverse
from django.contrib.auth import logout
from django.views.generic import RedirectView
class LogoutView(RedirectView):
"""
A view that logout user and redirect to homepage.
"""
@laozhu
laozhu / fix-psycopg2-error.sh
Created December 2, 2013 09:15
fix pscopg2 error for py3k and py2k
# fix psycopg2 error for py3k
sudo apt-get install python3-dev libpq-dev
# fix psycopg2 error for py2k
sudo apt-get install python-dev libpq-dev