Skip to content

Instantly share code, notes, and snippets.

@shellexy
shellexy / format_html.py
Created March 26, 2012 06:39
py 给 html 添加适当换行,以便版本管理
# -*- coding: UTF-8 -*-
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
import re
def format_html(html):
'''给 html 添加适当换行,以便版本管理
'''
html = re.sub('\n?\ ?<(address|blockquote|center|dir|div|dl|fieldset|form|h1|h2|h3|h4|h5|h6|hr|isindex|menu|noframes|noscript|ol|p|pre|table|ul|dd|dt|frameset|li|tbody|td|tfoot|th|thead|tr)([^>]*?)>', '\n<\\1\\2>', html)
html = re.sub('</(address|blockquote|center|dir|div|dl|fieldset|form|h1|h2|h3|h4|h5|h6|hr|isindex|menu|noframes|noscript|ol|p|pre|table|ul|dd|dt|frameset|li|tbody|td|tfoot|th|thead|tr)([^>]*?)>\ ?\n?', '</\\1\\2>\n', html)
@shellexy
shellexy / newx.sh
Created March 22, 2012 06:10
启动 Xephyr 来测试(可能挂掉 X 的)程序
#!/bin/sh -x
SIZE=1270x710
unset SESSION_MANAGER XDG_SESSION_COOKIE DBUS_SESSION_BUS_ADDRESS DESKTOP_SESSION
#Xephyr -screen 1270x715 -ac +bs +xinerama -fakexa -dpi 110 :3 &
Xephyr -zaphod -screen $SIZE -ac +bs +xinerama -dpi 110 :3 &
sleep 1s
export DISPLAY=:3
xrdb < ~/.Xresources
eval `dbus-launch --sh-syntax`
export XMODIFIERS=@im=fcitx QT_IM_MODULE=xim GTK_IM_MODULE=xim ; fcitx & sleep 1
@shellexy
shellexy / twip4-x-phx.diff
Created February 18, 2012 00:44
让 twip4 api 限额提高到 1000
--- twip/include/twitteroauth.php 2012-02-18 08:13:25.000000000 +0000
+++ twip/include/twitteroauth.php 2012-02-18 08:14:27.000000000 +0000
@@ -219,6 +219,8 @@
if (!empty($postfields)) {
$url = "{$url}?{$postfields}";
}
+ case 'GET':
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-PHX: true'));
}
@shellexy
shellexy / networkid.html.txt
Created December 17, 2011 03:53
RT @cxiaoji 蛋疼前40小时共采样224441条简体中文推,约为繁体两倍,以简体中文为主力语言的独立id 31107个。刷屏排行见此: http://xiaoji-chen.com/network/id.html
2011-12-15 2AM - 2011-12-16 6PM 不定期更新中
1 zgmlhx
2 gengdie
3 caoliu520
4 taidaonet
5 dengbot
6 banyilin
7 pinggaozhi
8 jackbilldarren
9 mlhshhs
@shellexy
shellexy / webstore 图片要求
Created December 6, 2011 07:30
This small tile image has been rejected due to the following reason: Too much whitespace Please review the guidelines, upload a new image and republish.
The Chrome Web Store is getting a new look! In the coming weeks, we’ll roll out a new version of the store that requires new images. If you want to provide images in the old sizes, as well, you can do so using the “current store look” tab.
Provide images that the store can use to promote your item. Although only the small box image is required, your item might be featured more prominently if you also provide a large box image, a marquee image, or both.
Fill the entire region, using square corners and no padding (full bleed).
Use a medium or dark background.
Avoid text in the image as much as possible.
Don’t put white elements along the edges of the image; the edges should be well defined.
Don't use a screenshot.
Your image should display well when reduced to half size.
Note: The size of promotional images in the current Chrome Web Store is different from the size in the new-look store.
@shellexy
shellexy / chromium.sh
Created November 26, 2011 11:17
苏酱要的 chromium.sh
#!/bin/bash
# ~/bin/chromium.sh
# 使用内存文件系统加速 chromium 运行
# 启动前和关闭后同步文件
CMD="chromium"
RAM_CACHE_DIR="/dev/shm/$USER-chrome-cache/"
DISK_CACHE_DIR="$HOME/.cache/chromium/"
@shellexy
shellexy / pygirconsole.py
Created November 15, 2011 12:38
提供 PyGtk3 的交互 shell
#!/usr/bin/python
# -*- coding: utf-8 -*-
# -*- Mode: python; c-basic-offset: 4 -*-
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
'''Interactive Python Gir (Gtk3) Console
@author: Jiahua Huang <[email protected]>
@license: LGPLv3+
'''
@shellexy
shellexy / get_chromium_snapshots.sh
Created November 7, 2011 13:47
下载 chromium 每日构建版
#!/bin/sh
get_chromium_snapshots(){
# 获取 snapshots 版 chromium-browser
VERSION="`wget -O- -nv http://build.chromium.org/f/chromium/snapshots/chromium-linux-reliability/LATEST`"
URL="http://build.chromium.org/f/chromium/snapshots/chromium-linux-reliability/$VERSION/chrome-linux.zip"
## 考虑已经下载的情况
touch VERSION
[ "`cat VERSION`" == $VERSION ] && return
## 下载
@shellexy
shellexy / paveo-uuid.sh
Created October 28, 2011 15:25
P 大说:要把一个文件里的全部 UUID 字符串全部 替换 成新的 UUID 字符串,每个 UUID 不能一样
#!/bin/bash
paveo(){
REG="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
CMD=""
for i in `sed -rn "/$REG/=" $1 `
do
CMD="$CMD ; ${i}s/$REG/`uuid`/"
done
sed -r -i "$CMD" $1;
@shellexy
shellexy / nautilus 不显示桌面菜单栏.diff
Created October 26, 2011 13:53
让 nautilus 在桌面没有使用 appmenu 时不要显示多余的屏幕顶部菜单栏
diff --git a/nautilus-3.2.0/src/nautilus-desktop-window.c b/nautilus-3.2.0/src/nautilus-desktop-window.c
--- a/nautilus-3.2.0/src/nautilus-desktop-window.c
+++ b/nautilus-3.2.0/src/nautilus-desktop-window.c
@@ -246,6 +246,11 @@ nautilus_desktop_window_constructed (GOb
g_signal_connect_swapped (nautilus_preferences, "changed::" NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
G_CALLBACK (nautilus_desktop_window_update_directory),
window);
+
+ GtkWidget * menubar_parent = gtk_widget_get_parent (NAUTILUS_WINDOW (window)->details->menubar);
+ GtkWidget * menubar_viewport = gtk_viewport_new (NULL, NULL);