Skip to content

Instantly share code, notes, and snippets.

View wenjianhn's full-sized avatar
🐢

Jian Wen wenjianhn

🐢
  • Xiaomi
  • Beijing, China
  • 06:17 (UTC +08:00)
View GitHub Profile
@wenjianhn
wenjianhn / .emacs
Created November 5, 2012 03:21
Go to nova launchpad bug page
(global-set-key [(S-f11)] 'browse-url-nova-bug)
(defun browse-url-nova-bug (start end)
(interactive "r")
(let ((n (current-word)))
(browse-url (concat "https://bugs.launchpad.net/nova/+bug/"
n)))
)
@wenjianhn
wenjianhn / .emacs
Created December 5, 2012 09:51
nose_[|un]set_trace
(global-set-key [(f8)] 'nose_set_trace)
(global-set-key [(C-f8)] 'nose_unset_trace)
(fset 'nose_set_trace
"import nose; nose.tools.set_trace();#:\C-x\C-s; \C-a\C-xr .")
(fset 'nose_unset_trace
"\C-xrj.\C-k\C-k")
@wenjianhn
wenjianhn / rysnc-without-ssh
Created January 7, 2013 03:01
patch against a5dc49c1e2d3173a0d336beb260bacad7441d99a
commit 9ec031bdee4633a3386cddfca791330680834b69
Author: Jian Wen <[email protected]>
Date: Fri Sep 14 17:42:21 2012 +0800
libvirt: Add copying image via rsync without ssh support
Change-Id: I4f4ec1b8466a4e8a8337f56f60473efc3b6bac00
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 41bbd2d..281d34b 100644
@wenjianhn
wenjianhn / conntrack-i-benchmark
Created April 3, 2013 14:02
"conntrack -I" benchmark
#!/bin/bash
if [[ $UID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
service conntrackd stop
# stop conntrackd.The daemon maybe writes the information about destroyed connections to a logfile.
# /var/log/conntrackd-stats.log
@wenjianhn
wenjianhn / modify_dns_record.sh
Created June 17, 2013 00:44
#cloudflare modify dns record
#!/bin/bash -e
if [[ $1 == "" ]]
then
file=`basename $0`
echo "Usage:"
echo " $file IP"
# TODO(wenjianhn): subname name and more as args
# echo: example
exit 1
vncviewer -nocursorshape -quality 0 -compresslevel 9 -encodings Tight -bgr233 localhost:5902
@wenjianhn
wenjianhn / set-repo-and-mirror.sh
Last active August 29, 2015 14:00
Set centos repos and pip mirror for openstack developers who live in China mainland.
function setup_mirror() {
cd /etc/yum.repos.d/
rm -f CentOS-Base.repo
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
wget http://ftp.sjtu.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
rm -f epel-release-6-8.noarch.rpm
mv epel.repo epel.repo.bak
@wenjianhn
wenjianhn / is-patch-merged-as-commit.sh
Created April 29, 2014 03:43
Check if a patch has already been merged as a specified commit.
#!/bin/bash
if [[ -z $2 ]]; then
echo -e "Usage:\n $0 <patch> <commit>"
exit 1
fi
PATCH=$1
COMMIT=$2
@wenjianhn
wenjianhn / open-tb-top-line.sh
Created April 30, 2014 10:51
open the top line of the first Traceback
./run_tests.sh nova.tests.network.test_manager.VlanNetworkTestCase.test_duplicate_vlan_raises || sed -n '/ File /{p;q;}' subunit.log | sed s/,//g | awk '{system("emacsclient " "+" $4 " " $2)}'
@wenjianhn
wenjianhn / suspend_host_if_guest_shutdown
Created August 19, 2014 01:23
suspend host if guest shutdown
while true; do virsh list | grep win7; if [[ $? -ne 0 ]]; then pm-suspend; fi; sleep 10; done