This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding=utf-8 | |
import urlparse | |
import unittest | |
def convert_relative_to_absolute(url, base_url): | |
base_url = base_url or '' | |
if not url: | |
return base_url |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A class or plugin of ajax submit form with success callback method | |
class AjaxForm | |
#ajax submit class | |
constructor: (form) -> | |
@form = form | |
init: (callback) -> | |
@form.submit => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.extend | |
historyPush: (options) -> | |
settings = | |
bind: '' | |
loader: '' | |
target: '' | |
callback: null | |
settings = $.extend settings, options |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
闰年: 四年一闰,百年不闰,四百年再闰 | |
""" | |
def is_bissextil_year(year): | |
if (year % 4 == 0) and (year % 100 != 0): | |
return True | |
if year % 400 == 0: | |
return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding=utf-8 | |
import unittest | |
# 单例类 | |
class MyClassA(object): | |
_instance = None | |
def __init__(self): | |
self._a = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 日期分段类 | |
*/ | |
abstract class DateStep { | |
const DAYTIME = 86400 | |
const WEEKTIME = 86400 * 7 | |
protected $startTime; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MysqlConnectorError extends Exception {} | |
/** | |
* Mysql 连接管理类 | |
* | |
* @author Sarah <tonshlee@gmail.com> | |
* | |
* <code> | |
* MysqlManager::instance() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @author tonsh | |
* | |
* A set of common used functions | |
*/ | |
/** | |
* 将数字字符串每3位添加一个逗号(从右向左) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
import datetime | |
import unittest | |
def strptime(date_str): | |
""" 不确定 date_str 格式的字符串与日期转换 """ | |
if isinstance(date_str, datetime.datetime): | |
return date_str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() { | |
int a = 1; | |
printf("%p\n", &a); // --> 0x7fff614d1a74 | |
a++; | |
printf("%p\n", &a); // --> 0x7fff614d1a74 | |
int b = a; | |
printf("%p\n", &b); // --> 0x7fff658c8a70 | |
return 0; |
OlderNewer