Skip to content

Instantly share code, notes, and snippets.

@pyKun
pyKun / centos.ustack
Last active February 10, 2022 18:53
Worked kickstart file for a standard centos
# centos_minimal_livecd.ks
# Created by AndrewSerk
part / --size 8192 --fstype ext4
lang en_US.UTF-8
keyboard us
timezone US/Eastern
auth --useshadow --enablemd5
selinux --disabled
firewall --disabled
#!/bin/bash
# on centos minimal
yum install gcc
yum install make
yum install ncurses-devel
yum install lua lua-devel
yum install ruby ruby-devel
yum install python python-devel
yum install perl perl-devel
@pyKun
pyKun / gist:7887227
Created December 10, 2013 08:14
strace log
stat("/usr/lib/python2.7/_weakrefset", 0x7fff61cf0ce0) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.7/_weakrefset.x86_64-linux-gnu.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.7/_weakrefset.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.7/_weakrefsetmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.7/_weakrefset.py", O_RDONLY) = 8
open("/usr/lib/python2.7/_weakrefset.pyc", O_RDONLY) = 9
read(9, "!\0\0\0/usr/lib/python2.7/_weakrefs"..., 4096) = 1191
stat("/home/hk/tr/weakref", 0x7fff61cf22e0) = -1 ENOENT (No such file or directory)
open("/home/hk/tr/weakref.x86_64-linux-gnu.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/hk/tr/weakref.so", O_RDONLY) = -1 ENOENT (No such file or directory)

Google Speech To Text API

Base URL: https://www.google.com/speech-api/v1/recognize
It accepts POST requests with voice file encoded in FLAC format, and query parameters for control.

Query Parameters

client
The client's name you're connecting from. For spoofing purposes, let's use chromium

lang
Speech language, for example, ar-QA for Qatari Arabic, or en-US for U.S. English

@pyKun
pyKun / keep_exc.py
Last active December 19, 2015 12:28
over covering on sys.exc_info()
#!/usr/bin/env python
#-*- coding:utf-8 -*-
# Author: Kun Huang <academicgareth@gmail.com>
# Created Time: 06/06/13 22:23:18 (CST)
# Modified Time: 07/09/13 12:03:40 (CST)
import sys
try:
raise ValueError('ddd')
except Exception as dd:
dd_exc = sys.exc_info()
#!/usr/bin/env python
"""Split large file into multiple pieces for upload to S3.
S3 only supports 5Gb files for uploading directly, so for larger CloudBioLinux
box images we need to use boto's multipart file support.
This parallelizes the task over available cores using multiprocessing.
Usage:
s3_multipart_upload.py <file_to_transfer> <bucket_name> [<s3_key_name>]
@pyKun
pyKun / test_xattr.sh
Created June 9, 2013 10:04
test swift object server xattr support
truncate -s 50MB hk.img
mkfs.vfat hk.img
mount hk.img /srv/node -o loop
swift-object-server start
#!/usr/bin/env python
"""Split large file into multiple pieces for upload to S3.
S3 only supports 5Gb files for uploading directly, so for larger CloudBioLinux
box images we need to use boto's multipart file support.
This parallelizes the task over available cores using multiprocessing.
Usage:
s3_multipart_upload.py <file_to_transfer> <bucket_name> [<s3_key_name>]
@pyKun
pyKun / boto_test_cors.py
Last active December 17, 2015 18:18
test swift3 middleware
#!/usr/bin/env python
#-*- coding:utf-8 -*-
# Author: Kun Huang <academicgareth@gmail.com>
# Created Time: 05/24/13 11:47:24 (CST)
# Modified Time: 05/27/13 16:15:33 (CST)
import boto
from boto.s3.connection import S3Connection
conn= S3Connection(
#!/bin/bash
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
yum groupinstall "Development tools"
yum install zlib-devel
yum install bzip2-devel openssl-devel ncurses-devel
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
tar xf Python-2.7.3.tar.bz2
cd Python-2.7.3