Skip to content

Instantly share code, notes, and snippets.

View lbj96347's full-sized avatar

lbjhk lbj96347

View GitHub Profile
@lbj96347
lbj96347 / python_utc_local_time.py
Created September 16, 2013 09:24
Use Python to change UTC time to Localtime.利用Python将国际标准时间改为本地时间
from dateutil import tz
from datetime import datetime
# UTC Zone
from_zone = tz.gettz('UTC')
# China Zone
to_zone = tz.gettz('Asia/Shanghai')
utc = datetime.utcnow()
@lbj96347
lbj96347 / array-prototype.js
Created September 9, 2013 03:41
ECMAScript5 array method wrote by Javascript.
/*!
* JavaScript Library v0.1 For Array prototype
* Copyright 2013, CashLee (cashlee96347@gmail.com)
*/
(function () {
function extend(target, props) {
for (var m in props) {
if (target[m] === undefined) target[m] = props[m];
}
}
//
// FontRegistry.h
// Tabris
//
// Created by Jordi Böhme López on 25.07.12.
// Copyright (c) 2012 EclipseSource.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
@lbj96347
lbj96347 / interview.js
Created June 21, 2013 08:54
找出3个数最大的乘积
/*
* 题目:
*
* 给定一个n * n的矩阵,例如:
* 10 45 90 11
* 23 68 29 09
* 49 39 23 78
* 46 92 21 90
*
* 写一个函数找出连续三个数的最大的乘积,条件如下:
@lbj96347
lbj96347 / python_ua_judgement.py
Created June 17, 2013 09:02
python_ua_judgement
import re
# device judgement
reg_b = re.compile(
r"(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino",
re.I | re.M)
reg_v = re.compile(
r"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|
@lbj96347
lbj96347 / php_ua_judgement.php
Last active December 18, 2015 14:09
php_ua_judgement_for_mobile_browsers
<?php
$agent;
function is_mobile(){
//正则表达式,批配不同手机浏览器UA关键词。
$regex_match="/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|";
$regex_match.="htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|";
$regex_match.="blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|";
$regex_match.="symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|";
$regex_match.="jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220";
$regex_match.=")/i";
@lbj96347
lbj96347 / JadeWebpageTemplate.jade
Created June 16, 2013 14:11
Jade_Webpage_Template
!!!5
html
head
meta(http-equiv="content-type", content="text/html; charset=UTF-8")
meta(name="viewport", content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0")
meta(name="apple-mobile-web-app-capable", content="yes")
meta(name="description", content="CashLee Homepage")
meta(name="author", content="CashLee")
meta(name="keywords",content="李秉骏,CashLee,HTML,CSS,XML,XHTML,JavaScript")
@lbj96347
lbj96347 / Git_Hooks_For_Auto_Deploy.sh
Created May 27, 2013 09:06
Git_Hooks_For_Auto_Deploy
#!/bin/sh
#
# git autodeploy script when it matches the string "[deploy]"
#
# @author cashlee
# @link http://cashlee.info
# @version 0.1
#
# Usage:
# 1. put this into the post-receive hook file itself below
@lbj96347
lbj96347 / mysqlHandleString.sql
Created December 27, 2012 07:08
Handle String by Mysql SQL Mysql处理字符串
/* mysql 字符串处理 */
SELECT * from `appmusic` WHERE instr(ALBUMLOGO, '.gif') > 0;
@lbj96347
lbj96347 / Obejctive-CLoadOnlineImage.m
Last active December 10, 2015 00:29
Objective-C Cocoa Load Online Image
- (BOOL) loadWebImage
{
BOOL result = NO;
UIImage* image=nil;
NSString* path =[NSString stringWithFormat: @"http://www.cashlee.me/images/cashlee.jpeg",[self.title UTF8String]];
NSURL* url = [NSURL URLWithString:[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];//网络图片url
NSData* data = [NSData dataWithContentsOfURL:url];//获取网咯图片数据
if(data!=nil){
StampUtility* theUtil = [[[StampUtility alloc] init] autorelease];//使用autorelease 实现自动释放资源,主要用于临时变量
image = [[UIImage alloc] initWithData:data];//根据图片数据流构造image