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 / 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 / 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';
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 / 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
@earthday
earthday / 上海长城宽带右下角广告代码.html
Last active April 16, 2018 12:37
上海长城宽带右下角广告代码
<script language="javascript">
<!--
var ua = navigator.userAgent;
var $IE = (navigator.appName == "Microsoft Internet Explorer");
var $IE5 = $IE && (ua.indexOf('MSIE 5') != -1);
var $IE5_0 = $IE && (ua.indexOf('MSIE 5.0') != -1);
var $Gecko = ua.indexOf('Gecko') != -1;
var $Safari = ua.indexOf('Safari') != -1;
var $Opera = ua.indexOf('Opera') != -1;
var $Mac = ua.indexOf('Mac') != -1;
@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
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
<title>Index Page</title>
<style type="text/css">
.yui-skin-sam .yui-dt-liner { white-space:nowrap; }
</style>
<script type="text/javascript">
YAHOO.example.Data = {
bookorders: [
/*
*
* 此问题源自于BinarySearch中的求中数的小陷阱。
* 查看了微软的源代码,在1.x时代是如line01所示的方案,显然是有错的。
* 在2.0后改为line03,无错。
* 由于疏忽,我上来写成了line02,于是也出错了,一查看原来是优先级没搞混了。
*
*/
using System;
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;
static void Main(string[] args)
{
using (SvnClient client = new SvnClient())
{
SvnInfoEventArgs serverInfo;
SvnInfoEventArgs clientInfo;
SvnUriTarget repos = new SvnUriTarget("http://svn.test.com/demo");
SvnPathTarget local = new SvnPathTarget(@"d:\Work\Code\demo");
client.GetInfo(repos, out serverInfo);