Skip to content

Instantly share code, notes, and snippets.

View binzeehale's full-sized avatar

Zheng Bin binzeehale

  • Nsfocus
  • Chengdu
View GitHub Profile
@binzeehale
binzeehale / run_as_daemon.py
Created August 19, 2014 03:18
run_as_daemon
def run_as_daemon(stdin = '/dev/null',stdout='/dev/null', stderr = '/dev/null'):
'''
@brief 以daemon的方式运行程序
@details 以daemon的方式运行程序
@param stdin (string) 重定向标准输入
@param stdout (string) 重定向标准输出
@param stderr (string) 重定向错误输出
'''
try:
@binzeehale
binzeehale / get_values.py
Created August 19, 2014 03:40
获取python类的所有属性和值的对
for property, value in vars(theObject).iteritems():
print property, ": ", value
// or
import inspect
for attr, value in inspect.getmembers(obj):
print attr, value
@binzeehale
binzeehale / clearfix.css
Created August 20, 2014 02:17
clearfix
.clearfix:before,
.clearfix:after {
content: " "; /* 1 */
display: table; /* 2 */
}
.clearfix:after {
clear: both;
}
@binzeehale
binzeehale / gist:fc011f49bfc303a5f6f4
Last active August 29, 2015 14:07
Font Settings.
/* 14px ~ 16px Best font settings */
font-family:Lucida Sans Unicode, Hiragino Sans GB, WenQuanYi Micro Hei, Verdana, Aril, sans-serif;
/* 12px ~ 13px Best font settings */
font-family:Lucida Sans Unicode, Verdana, Aril, sans-serif;
@binzeehale
binzeehale / grunt watch
Last active August 29, 2015 14:07
Grunt watch ERROR , resoltion
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
@binzeehale
binzeehale / raw_string.py
Created October 28, 2014 11:14
Make r in string. raw_string.
def raw_string(s):
if isinstance(s, str):
s = s.encode('string-escape')
elif isinstance(s, unicode):
s = s.encode('unicode-escape')
return s
@binzeehale
binzeehale / bookmark
Created November 6, 2014 11:00
Bookmark stylesheet gist.
.bookmark{
background: #b00;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b00), color-stop(100%,#900));
background-image: -webkit-linear-gradient(top, #b00 0%, #900 100%);
background-image: -moz-linear-gradient(top, #b00 0%, #900 100%);
background-image: -o-linear-gradient(top, #b00 0%, #900 100%);
background-image: -ms-linear-gradient(top, #b00 0%, #b00 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b00', endColorstr='#900',GradientType=0 );
background-image: linear-gradient(top, #b00 0%, #900 100%);
@binzeehale
binzeehale / require-common-gloably.js
Last active August 29, 2015 14:10
The write way for require/common/globally javascript lib
(function(name, definition) {
if (typeof module != 'undefined') module.exports = definition();
else if (typeof define == 'function' && typeof define.amd == 'object') define(definition);
else this[name] = definition();
}('mod', function() {
//This is the code you would normally have inside define() or add to module.exports
return {
sayHi: function(name) {
console.log('Hi ' + name + '!');
}
@binzeehale
binzeehale / gulp gist.
Created January 6, 2015 06:07
gulp gist.
/*!
* gulp
* $ npm install gulp-ruby-sass gulp-autoprefixer gulp-minify-css gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev
*/
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
@binzeehale
binzeehale / grunt gist
Created January 6, 2015 06:09
grunt gist
/*!
* Grunt
* $ npm install grunt-contrib-uglify grunt-autoprefixer grunt-contrib-cssmin grunt-contrib-imagemin grunt-contrib-sass grunt-contrib-watch grunt-contrib-concat grunt-contrib-clean grunt-contrib-jshint grunt-notify --save-dev
*/
module.exports = function(grunt) {
grunt.initConfig({
// Sass