Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View earthday's full-sized avatar
🔋
Power~!

Bright Chen earthday

🔋
Power~!
View GitHub Profile
@earthday
earthday / 0_reuse_code.js
Created August 19, 2014 06:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@earthday
earthday / How to update Python to 2.7.8 on CentOS6.x
Last active August 29, 2015 14:10
How to update Python to 2.7.8 on CentOS6.x
sudo yum update -y
sudo yum groupinstall -y 'development tools'
sudo yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel xz-libs wget
sudo wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz
tar xvf Python-2.7.8
cd Python-2.7.8
sudo ./configure --prefix=/usr/local
sudo make
sudo make altinstall
sudo wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
conn = pymssql.connect(server, user, password, "tempdb")
cursor = conn.cursor()
cursor.execute('SELECT * FROM persons WHERE salesrep=%s', 'John Doe')
for row in cursor:
print('row = %r' % (row,))
conn.close()
@earthday
earthday / test.js
Last active August 29, 2015 14:11 — forked from jmyrland/test.js
Socket-io load test
/**
* Modify the parts you need to get it working.
*/
var should = require('should');
var request = require('../node_modules/request');
var io = require('socket.io-client');
var serverUrl = 'http://localhost';
@earthday
earthday / python_logging_example.py
Last active August 29, 2015 14:15
Python logging example
import os
import logging
import codecs
import yaml
# config the logging
current_folder = os.path.dirname(os.path.realpath(__file__))
logging_config_filename = os.path.join(current_folder, 'python_logging_example.yaml')
logging.config.dictConfig(yaml.load(codecs.open(logging_config_filename, 'r', 'utf-8')))
logger = logging.getLogger('commonLog')
@earthday
earthday / tox_example.ini
Created February 11, 2015 06:55
tox_example.ini
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
[tox]
skipsdist = True
@earthday
earthday / html5.html
Created February 24, 2015 03:38
The template of html5 which is copied from http://m.kissyui.com/docs/quickstart
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>KISSY MINI Mobile Demo Template</title>
<!--
width=device-width:让文档的宽度与设备的宽度保持一致,且文档最大的宽度比例是1.0
initial-scale=1:初始的缩放比例
maximum-scale=1:允许用户缩放到的最大比例(对应还有个minimum-scale)
user-scalable=no:不允许用户手动缩放
@earthday
earthday / convert_to_int_with_default_zero.js
Last active August 29, 2015 14:21
Convert to integer with a default value of 0.
(function(priority) {console.log(priority); return priority && + priority | 0 || 0; })()
// undefined
// 0
(function(priority) {console.log(priority); return priority && + priority | 0 || 0; })(45)
// 45
// 45
(function(priority) {console.log(priority); return priority && + priority | 0 || 0; })('a')
// a
@earthday
earthday / self-signed-ssl-certificate.txt
Created July 11, 2015 08:16
create a self-signed SSL certificate
# Become root first !
$ mkdir /etc/ssl/self-signed && cd /etc/ssl/self-signed
$ openssl genrsa -des3 -out server.key 1024
$ openssl rsa -in server.key -out server.key.insecure
$ mv server.key server.key.secure && mv server.key.insecure server.key
$ openssl req -new -key server.key -out server.csr
$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;