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 / gist:4471752
Last active October 21, 2016 23:14
# -*- coding: utf-8 -*-
from lxml import etree
from bottle import Bottle, run, request
import sae
app = Bottle()
"""
此处省略若干行
"""
@laozhu
laozhu / gist:4500892
Created January 10, 2013 10:01
通过Javascript和Email地址获取特定大小的Gavatar头像
$(document).ready(function(){
var MD5 = function (string) {
function RotateLeft(lValue, iShiftBits) {
return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
}
function AddUnsigned(lX,lY) {
var lX4,lY4,lX8,lY8,lResult;
@laozhu
laozhu / gist:4679062
Last active December 11, 2015 23:48
verify a PNG file and get image dimensions
#!/usr/bin/env python
import struct
def get_image_info(data):
if is_png(data):
w, h = struct.unpack('>LL', data[16:24])
width = int(w)
height = int(h)
@laozhu
laozhu / gist:4721630
Created February 6, 2013 10:13
menu editor
sudo apt-get install alacarte
@laozhu
laozhu / gist:4722314
Created February 6, 2013 12:45
当没法卸载device时候,加上 `-l` 参数就可以了
umount -l /mnt/funtoo
@laozhu
laozhu / regexp.md
Last active December 14, 2015 05:28
正则表达式匹配模式

电子邮件

Javascript Version

/^[\w\.\-]+@([\w\-]+\.)+[A-z]{2-6}$/

Python Version

(\b[\w.-]+@([\w-]+.)+[A-z]{2,6}\b)

@laozhu
laozhu / GSWD.md
Last active December 14, 2015 05:59
getting started with django cookbook

Upgrade the system

sudo nano /etc/apt/source.list
sudo apt-get update
sudo apt-get upgrade

Do some cleans

sudo apt-get clean

sudo apt-get autoclean

@laozhu
laozhu / kernel-configure.md
Last active October 31, 2019 13:14
Linux 内核编译指南

编译原则

  1. 确定 的功能一定编译进内核
  2. 可能 的功能编译为模块
  3. 不确定 的功能保留默认值,或编译为模组
  4. 选择 双号 版本内核,忽略 单号 内核

准备工作

@laozhu
laozhu / make.conf
Created March 20, 2013 13:33
/etc/make.conf for funtoo desktop
CFLAGS="-march=corei7 -O2 -pipe"
CXXFLAGS="${CFLAGS}"
CHOST="x86_64-pc-linux-gnu"
LINGUAS="en"
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
PORTAGE_NICENESS="15"
MAKEOPTS="-j5"
INPUT_DEVICES="evdev keyboard mouse synaptics"
VIDEO_CARDS="radeon intel"
@laozhu
laozhu / install-funtoo.md
Last active December 15, 2015 04:59
Install Funtoo Desktop on Dell Inspiron 7520 SE
# emerge --sync
# emerge -av wqy-microhei 

GPT/GUID partition table

gdisk /dev/sda

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          411647   200.0 MiB   8300  Linux filesystem

2 411648 923647 250.0 MiB EF00 EFI System