This file contains 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
from django.http import HttpResponse, HttpResponseForbidden | |
from django.conf import settings | |
from functools import wraps | |
from django.utils.decorators import available_attrs | |
from utils import ip_in_expected_networks | |
def limit_access_by_ip(allowed_ips=settings.INTERNAL_IPS): | |
'''Decorator to limit access in specified IP areas.''' | |
def decorator(view_func): | |
@wraps(view_func, assigned=available_attrs(view_func)) |
This file contains 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
/** | |
* 回到页面顶部 | |
* @param acceleration 加速度 | |
* @param time 时间间隔 (毫秒) | |
**/ | |
function goTop(acceleration, time) { | |
acceleration = acceleration || 0.1; | |
time = time || 16; | |
var x1 = 0; |
This file contains 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
function shake(e, oncomplete, distance, time) { | |
// Handle arguments | |
if (typeof e === "string") e = document.getElementById(e); | |
if (!time) time = 500; | |
if (!distance) distance = 5; | |
var originalStyle = e.style.cssText; // Save the original style of e | |
e.style.position = "relative"; // Make e relatively positioned | |
var start = (new Date()).getTime(); // Note the animation start time | |
animate(); // Start the animation | |
// This function checks the elapsed time and updates the position of e. |
This file contains 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 | |
from django.http import HttpResponse | |
import md5 | |
import cStringIO | |
import Image, ImageDraw, ImageFont, random | |
from datetime import datetime | |
from os import path | |
def get_validatecode_img(request): | |
IMG_W = 100 | |
IMG_H = 35 |
This file contains 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
$(document).ready(function(){ | |
$('#change_email_form').validate({ | |
rules: { | |
email1: {required:true, email:true}, | |
email2: {required:true, email:true, equalto:"#id_email1"}, | |
}, | |
messages: { | |
email2: { | |
equalto: '两次输入邮箱地址不一致' | |
} |
This file contains 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 jsonp(f): | |
"""Wrap a json response in a callback, and set the mimetype (Content-Type) header accordingly | |
(will wrap in text/javascript if there is a callback). If the "callback" or "jsonp" paramters | |
are provided, will wrap the json output in callback({thejson}) | |
Usage: | |
@jsonp | |
def my_json_view(request): | |
d = { 'key': 'value' } |
This file contains 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
✔ × | |
› ‹ | |
» « | |
← → ↩ ↪ ↘ ↙ ⇛ ⇚ #for i in range(8600, 8700): print unichr(i) | |
⊕ ⌚ | |
≥ ≤ | |
■ | |
❤ ❥ ✾ ❣ ❖ ❢ ❦ ❧ ⥀ ⥁ ❍ ⥉ ✩ ✪ ✫ ✬ ✭ ✮ ✯ ✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✻ ✽ ✾ ✿ ❀ ❁ ❂ #for i in range(10000, 10100): print unichr(i) | |
🦄 |
This file contains 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
#!/usr/bin/env node | |
function capital_money(value) { | |
function get_tidy_value(value) { | |
var s_value = value.toFixed(2); | |
if(s_value.indexOf('.') >= 0) { | |
var int_part = s_value.split('.')[0]; | |
var float_part = s_value.split('.')[1]; | |
} else { | |
var int_part = s_value; |
This file contains 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
#!/usr/bin/python | |
# coding=utf-8 | |
''' | |
一个岛上居住着两类人——骑士和流氓。骑士说的都是真话,而流氓总是说谎。 | |
现在碰到了岛上的两个人A和B,如果A说“B是骑士”,B说“我们两人不是一类人”。 | |
请判断A、B两人到底是骑士还是流氓。 | |
''' | |
class Speaker(object): | |
'''说话人, 可能是A, 也可能是B''' |
This file contains 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
/* 基础highcharts选项, 适用于每日行情数据 | |
*/ | |
var baseHighChartOpts = { | |
chart: { | |
zoomType: $(window).width() >= 800? 'x': null, //针对宽度大于800的窗口启用x轴缩放 | |
height: 320 | |
}, | |
title: { | |
text: null |
OlderNewer