Skip to content

Instantly share code, notes, and snippets.

Alfred Zhou adaiguoguo

Block or report user

Report or block adaiguoguo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@adaiguoguo
adaiguoguo / close_fds
Last active Aug 29, 2015
don't close_fds on Windows
View close_fds
return Popen([sys.executable, '-c', cmd, '--existing', cf] + argv,
- stdout=PIPE, stderr=PIPE, close_fds=True,
+ stdout=PIPE, stderr=PIPE, close_fds=(sys.platform != 'win32'),
)
@adaiguoguo
adaiguoguo / _.md
Last active Aug 29, 2015 — forked from klange/_.md
View _.md

Since this is on Hacker News and reddit...

  • No, I don't distribute my résumé like this. A friend of mine made a joke about me being the kind of person who would do this, so I did (the link on that page was added later). My actual résumé is written in BSD mandoc.
  • I apologize for the use of _t in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".
  • Since people kept complaining, I've fixed the assignments of string literals to non-const char *s.
  • My use of type * name, however, is entirely intentional.
  • If you're using an older compiler, you might have trouble with the anonymous unions and the designated initializers - I think gcc 4.4 requires some extra braces to get them working together. Anything reasonably recent should work fine. Clang and gcc (newer than 4.4, at
View Gerrit-Jenkins-Sonar
reponame = os.environ['GERRIT_PROJECT']
repo = reponame.replace('/','-')
print repo
file=open('sonar-project.properties','w')
s='''sonar.projectKey='''+repo+'''\nsonar.projectName='''+repo+'''\nsonar.projectVersion=1.0\nsonar.sources=.\nsonar.sourceEncoding=UTF-8'''
file.write(s)
file.close()
@adaiguoguo
adaiguoguo / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@adaiguoguo
adaiguoguo / lvmdisk.sh
Last active Aug 29, 2015
lvm 分区 需默认安装lvm2 /srv 10g /home 10g /data 10g
View lvmdisk.sh
umount /dev/vdb1 /data
fdisk -c -u /dev/vdb <<EOF
D
w
EOF
sleep 1s
fdisk -c -u /dev/vdb <<EOF
n
p
1
@adaiguoguo
adaiguoguo / postgres.sql
Created Nov 5, 2015
postgres count gitlab pr &push
View postgres.sql
SELECT aa.datetime,
aa.cc pushed,
bb.cc pr
FROM (SELECT To_char(created_at, 'YYYY-MM-DD') datetime,
Count (1) cc
FROM EVENTS
WHERE action = 5
AND created_at > NOW() - '30 DAY'::INTERVAL
GROUP BY To_char(created_at, 'YYYY-MM-DD'),
target_type,
@adaiguoguo
adaiguoguo / extract.sh
Last active Jun 8, 2016 — forked from liaoyw/extract.sh
解压小能手
View extract.sh
# copy from http://www.tldp.org/LDP/abs/html/sample-bashrc.html
function extract() # Handy Extract Program
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
@adaiguoguo
adaiguoguo / lvremove.sh
Created Jul 20, 2016
老机器上lvremove
View lvremove.sh
#!/bin/sh
lvremove /dev/vol_vdb1/lvol0
lvremove /dev/vol_vdb1/lvol1
lvremove /dev/vol_vdb1/lvol2
pvremove /dev/vdb1 --force --force
fdisk -c -u /dev/vdb <<EOF
D
w
EOF
@adaiguoguo
adaiguoguo / power_check.sh
Last active Sep 6, 2016
检查宿主是否有cpu时钟休眠
View power_check.sh
#!/bin/bash
#
pro=$(dmidecode -t 1|grep Manufacturer|awk '{print $2}')
sys=$(lsb_release -a|grep ID |awk '{print $3}')
ver=$(lsb_release -a|grep Release|awk '{print $2}'|awk -F '.' '{print $1}')
if [[ $pro == Dell ]]
then
if [[ $sys == "CentOS" ]]
then
@adaiguoguo
adaiguoguo / goroutine-stacks-2017-03-09T214055+0800.log
Created Mar 9, 2017
var/run/docker/goroutine-stacks-2017-03-09T214055+0800.log
View goroutine-stacks-2017-03-09T214055+0800.log
goroutine 218 [running]:
github.com/docker/docker/pkg/signal.DumpStacks(0x18f6c6a, 0xf, 0x0, 0x0, 0x0, 0x0)
/root/rpmbuild/BUILD/docker-engine/.gopath/src/github.com/docker/docker/pkg/signal/trap.go:82 +0xfc
github.com/docker/docker/daemon.(*Daemon).setupDumpStackTrap.func1(0xc420b17da0, 0x18f6c6a, 0xf, 0xc420358200)
/root/rpmbuild/BUILD/docker-engine/.gopath/src/github.com/docker/docker/daemon/debugtrap_unix.go:19 +0xcb
created by github.com/docker/docker/daemon.(*Daemon).setupDumpStackTrap
/root/rpmbuild/BUILD/docker-engine/.gopath/src/github.com/docker/docker/daemon/debugtrap_unix.go:32 +0x10a
goroutine 1 [chan receive, 23656 minutes]:
main.(*DaemonCli).start(0xc42052ade0, 0x0, 0x1908125, 0x17, 0xc420087400, 0xc42050c2d0, 0xc42044e6c0, 0x0, 0x0)
You can’t perform that action at this time.