Skip to content

Instantly share code, notes, and snippets.

View webee's full-sized avatar
🎯
Focusing

webee.yw webee

🎯
Focusing
View GitHub Profile
@webee
webee / main.c
Created March 21, 2012 05:02
webee's hello world.
#include <stdio.h>
int
main(int argc, char *argv[])
{
printf("hello, world!");
return 0;
}
@webee
webee / gist:2715475
Created May 17, 2012 01:23
disqus universal code.
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'example'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
@webee
webee / pyenv.sh
Last active December 23, 2015 04:39
setup python environment: python2.7.5,easy_install, pip, virtualenv, ipython.#curl https://gist.githubusercontent.com/webee/6581853/raw/pyenv.sh |sudo sh
#!/bin/sh
#curl https://gist.githubusercontent.com/webee/6581853/raw/pyenv.sh |sudo sh
#set -x
#resource url.
#check root.
root=$(whoami)
if [ "$root" != "root" ];then
echo "need root privilege."
exit 1
fi
@webee
webee / python.sh
Last active December 23, 2015 04:39
if [ "${0:0:1}" != "-" ]; then
export PY_PROFILE=$(readlink -f $0)
fi
export PY_ROOT=/home/q/python
export PY_HOME=$PY_ROOT/default
export PY_ENV=$PY_ROOT/env
export PY_SRC=$PY_ROOT/src
export PY_XSRC=$PY_ROOT/xsrc
export PY_DEFAULT_ENV=main
@webee
webee / .vromerc
Last active December 26, 2015 19:19
.vromerc
" todo.
@webee
webee / generate_project_from_test.sh
Last active August 29, 2015 13:59
generate a maven jar project from test-maven-project.
#!/bin/bash
name=$1
username=webee
template=test-maven-project
function LOG_INFO() {
local msg=$1
echo "[$(date +'%Y-%m-%d %H:%M:%S.%N')][INFO] ${msg}"
@webee
webee / python_logging
Created May 28, 2014 03:27
python logging demo.
import logging
def get_logger():
level = logging.DEBUG
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(module)s[%(lineno)d] - %(funcName)s - %(message)s')
#!/bin/sh
#
# /etc/rc.d/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
@webee
webee / util.dateDiff.sh
Created September 11, 2014 07:18
linux date diff.
#/bin/env sh
date2stamp () {
date --utc --date "$1" +%s
}
stamp2date (){
date --utc --date "1970-01-01 $1 sec" "+%Y-%m-%d %T"
}
dateDiff (){
@webee
webee / SwfitObjectAssociateUtil
Last active September 17, 2015 10:17
associate object to class in swift.
// refer to: http://rosettacode.org/wiki/Add_a_variable_to_a_class_instance_at_runtime#Swift
// this is stupid, just inherit the target class.
import Foundation
class ObjectAssociateUtil {
static var objKeys = [String:UnsafePointer<()>]()
class func getAssociateObject<T:AnyObject, D>(target:T, by_key key:String) -> D? {
let objKeyName = "\(NSStringFromClass(target.dynamicType)).\(key)"
if let objKey = objKeys[objKeyName] {