Skip to content

Instantly share code, notes, and snippets.

@songxiaofeng1981
songxiaofeng1981 / test.py
Created November 23, 2012 01:25
python:getChannelIDs
#!/usr/bin/env python
import urllib2
import json
def get_channels():
channels = set()
url = "http://rcmsapi.chinacache.com:36000/customer/24quan/channels"
opener = urllib2.urlopen(url)
@songxiaofeng1981
songxiaofeng1981 / helloworld (1).user.js
Created November 22, 2012 06:48
monkey:getchannelid
// Hello World! example user script
// version 0.1 BETA!
// 2005-04-25
// Copyright (c) 2005, Mark Pilgrim
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
// --------------------------------------------------------------------
//
@songxiaofeng1981
songxiaofeng1981 / get_all_month_date.py
Created November 21, 2012 06:53
python:get_month_regrex
from dateutil import rrule
from datetime import datetime
import re
def get_dates():
dates = []
dates.append({"start":'201101010000',"end":'201101012359'})
return dates;
def beween_day():
a = '20110101'
@songxiaofeng1981
songxiaofeng1981 / test_regrex2.py
Created November 21, 2012 06:51
python:regrex-explain
#!/usr/bin/env python
#encoding=utf-8
#vim ft=python
#abstract: 演示Python中正则表达式的基本用法
#tag:Python RegExp example
import re
#辅助函数,打印一个matchobject的信息
@songxiaofeng1981
songxiaofeng1981 / Negative:all
Created November 16, 2012 14:16
RegRex:lookbehind all
# Lookaheads
jeffrey@envato.com
jeffrey@jeffrey-way.com
jeffrey@envato.edu
jeffrey@jeffrey-way.au
jeffrey@jeffrey-way.tv
正则匹配表达式: @.+(?=\.[a-z]{2,4})
解释:
@ 匹配@
. 匹配任意字符
@songxiaofeng1981
songxiaofeng1981 / negative lookbehind
Created November 16, 2012 09:54
RegExp:negative lookbehind
# negative lookbehind
display:box; box-shadow: 1px 2px 3px black; box-sizing: 100% 100%;
逐行解释:
(?<!: ) Negative lookbehind 不包含前面含有 : 号的box
[^;] 不是分号的所有字符
+ 前面不是分号的所有字符1个或多个
; 匹配一个分号
# negative lookbehind
display:box; box-shadow: 1px 2px 3px black; box-sizing: 100% 100%;
逐行解释:
(?<!: ) Negative lookbehind 不包含前面含有 : 号的box
[^;] 不是分号的所有字符
+ 前面不是分号的所有字符1个或多个
; 匹配一个分号
@songxiaofeng1981
songxiaofeng1981 / homework:init2.js
Created November 11, 2012 04:58
homework:javascript
it('inherts',function () {
var Model = new Class(
{
initialize:function (name) {
this.name = name;
},
save:function () {
return "my name is "+this.name;
//增加对象构造函数,call,apply 函数。 匿名函数,内存模型。
var Class = function() {
var klass = function() {
if(typeof klass.constructor == 'function'){
// klass.constructor (arguments[0])
console.log(arguments[0]);
console.log(arguments[1]);
// console.log(arguments[2]);
@songxiaofeng1981
songxiaofeng1981 / javascript:learn
Created November 11, 2012 02:58
learn javascript
var Class = function () {
var klass = function () {
this.initialize.apply(this,arguments) //this中没有init,找原型
};
klass.fn = klass.prototype;//todo 污染
return klass;
};