Skip to content

Instantly share code, notes, and snippets.

Avatar

Kun Huang pyKun

View GitHub Profile
View redhatsummit.log
//videos.cdn.redhat.com/summit2015/presentations/11500_racing-camel-with-bpm-and-red-hat-jboss-fuse.pdf
//videos.cdn.redhat.com/summit2015/presentations/13875_harnessing-big-data-with-hortonworks-data-platform-red-hat-jboss-data-virtualization.pdf
//videos.cdn.redhat.com/summit2015/presentations/12218_use-openshift-paas-to-accelerate-devops-continuous-delivery.pdf
//videos.cdn.redhat.com/summit2015/presentations/11322_whats-new-with-red-hat-jboss-operations-network.pdf
//videos.cdn.redhat.com/summit2015/presentations/13622_process-driven-application-development-using-red-hat-jboss-bpm-suite.pdf
//videos.cdn.redhat.com/summit2015/presentations/15846_strategy-vision-for-red-hat-management-solutions.pdf
//videos.cdn.redhat.com/summit2015/presentations/17850_development-architecture-for-application-centric-microservices-deployment-in-the-intercloud.pdf
//videos.cdn.redhat.com/summit2015/presentations/17854_red-hat-ceph-storage-and-network-solutions-for-software-defined-infrastructure-sdi.pdf
//videos.cdn.redhat.c
View sorted-topics-in-tokyo.txt
Protecting hybrid cloud environments from being breached
<https://www.openstack.org/summit/tokyo-2015/vote-for-speakers/presentation/3591>
System Domination: Config Management and Image Deployment
<https://www.openstack.org/summit/tokyo-2015/vote-for-speakers/presentation/3592>
Duct-tape, Bubblegum, and Bailing Wire
<https://www.openstack.org/summit/tokyo-2015/vote-for-speakers/presentation/3606>
Load Balancing as a Service, Liberty and Beyond
View pip.conf
[global]
index-url=http://pypi.openstack.org/openstack/
View mdserv
#!/usr/bin/python
"""
To use this to mimic the EC2 metadata service entirely, run it like:
# where 'eth0' is *some* interface. if i used 'lo:0' i got 5 second or so delays on response.
sudo ifconfig eth0:0 169.254.169.254 netmask 255.255.255.255
sudo ./mdserv 169.254.169.254:80
Then:
wget -q http://169.254.169.254/latest/meta-data/instance-id -O -; echo
curl --silent http://169.254.169.254/latest/meta-data/instance-id ; echo
View openstack-one.sh
/usr/libexec/qemu-kvm \
-name instance-00000001 \
-S -M rhel6.5.0 -no-kvm -m 512 \
-realtime mlock=off \
-smp 1,sockets=1,cores=1,threads=1 \
-uuid c6761dd9-f3f1-49c4-a9de-136f0bad6d8a \
-smbios type=1,manufacturer=Red Hat Inc.,product=OpenStack Nova,version=2014.1.1-3.el6,serial=564de42d-269e-f49a-6c7a-59f14f4e4b9c,uuid=c6761dd9-f3f1-49c4-a9de-136f0bad6d8a \
-nodefconfig \
-nodefaults \
-chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/instance-00000001.monitor,server,nowait \
View Description.md

I was tired of Chrome eating all my laptop resources so I decided to put some limit to it with cgroup.

As I was using Ubuntu 12.04 with support for cgroup, I installed the package cgroup-bin and add the following group to the file /etc/cgconfig.conf:

group browsers {
    cpu {
#       Set the relative share of CPU resources equal to 25%
        cpu.shares = "256";
    }
View vim_centos.sh
#!/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
View gist:7887227
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)
View google_speech2text.md

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 Dec 19, 2015
over covering on sys.exc_info()
View keep_exc.py
#!/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()