Skip to content

Instantly share code, notes, and snippets.

@gtt116
gtt116 / weird.py
Created March 2, 2015 07:48
python weird codes
"""
Why line 21 raise ??
"""
def error():
print 'foo'
class OK(object):
@gtt116
gtt116 / back_jenkins.sh
Created November 12, 2014 01:58
back jenkins
tar czf ~/jenkins_backup.tar.gz --exclude='var/lib/jenkins/logs/*' --exclude='var/lib/jenkins/jobs/*/builds/*' --exclude="var/lib/jenkins/jdk" '/var/lib/jenkins'
@gtt116
gtt116 / ceph disk(rbd).xml
Last active July 12, 2016 06:10
OpenStack Qemu domain XML file example
<emulator>/usr/bin/kvm</emulator>
<disk type='network' device='disk'>
<driver name='qemu' type='raw' cache='writeback' discard='unmap'/>
<auth username='cinder'>
<secret type='ceph' uuid='457eb676-33da-42ec-9a8c-9293d545c337'/>
</auth>
<source protocol='rbd' name='netbeta-vms/ecb16c09-277c-4b0b-927e-2baae90cd558_disk'>
<host name='10.180.0.47' port='6789'/>
<host name='10.180.0.48' port='6789'/>
</source>
@gtt116
gtt116 / lxc.xml
Last active August 29, 2015 14:08
Example lxc config file for libvirt
<domain type='lxc'>
<name>helloworld</name>
<uuid>7c3f13f0-6fcf-0e80-c3c3-5bc73607cda9</uuid>
<memory>102400</memory>
<currentMemory>102400</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='x86_64'>exe</type>
<init>/bin/sh</init>
</os>
@gtt116
gtt116 / HTTPConnection.py
Last active August 29, 2015 14:05
python http handler
#coding=gbk
from httplib import HTTPConnection,HTTPResponse
# request' header
headers = {
"User-Agent":"Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13",
"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language":"zh-cn,zh;q=0.5",
"Accept-Charset":"GB2312,utf-8;q=0.7,*;q=0.7",
@gtt116
gtt116 / cao_ni_ma.py
Last active July 12, 2017 09:05 — forked from edokeh/index.js
神兽保佑,远离bug
#
# The Animal Protects No Bug
# ~~~ ~~~
# __| |______| |__```
# | |
# | | ````
# | ````` | ```````
# | ████--████ | `````
# | | ```
# | _[_ |
@gtt116
gtt116 / gist:a43192f8ebf1992e5806
Last active August 29, 2015 14:05
to_unicode
# Borrow from http://farmdev.com/talks/unicode/
#
# Remember:
# file/network (8-bit string) ----decode() -----> unicode -----encode()--------> file/network
def to_unicode(obj, decoding='utf8'):
"""
decoding a 8-bit string to unicode
"""
if isinstance(obj, basestring):
{
"_default_" : {
"date_formats" : [
"yyyy-MM-dd HH:mm:ss.SSSZZ",
"yyyy-MM-dd HH:mm:ss",
"date_optional_time"
]
}
}
@gtt116
gtt116 / elasticsearch.yml
Created September 24, 2013 05:58
elasticsearch.yml
index:
analysis:
analyzer:
default:
type: whitespace
@gtt116
gtt116 / nvs-stacktash
Last active December 23, 2015 11:59
Add event_type in table panel.
{
"title": "NVS Intrumentation",
"services": {
"query": {
"idQueue": [
1,
2,
3,
4
],