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
import tornado.gen | |
import tornado.web | |
from tornado.platform.asyncio import AsyncIOMainLoop | |
from tornado.options import define, options, parse_command_line | |
import peewee | |
import asyncio | |
import peewee_async | |
import logging | |
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
//灵感来自: https://gist.github.com/tbranyen/1142129 | |
$(document).on("click", "a", function(event) { | |
// 如果一个链接的协议、域名、端口都和当前页面相同,则将其视为应用内的跳转链接,通过 pushState 进行处理; | |
// 否则作为普通外部链接,交由浏览器处理。 | |
// 不过当用户按下 Ctrl 等控制键时,因为涉及到浏览器原生的在新标签/页面打开链接的操作,一切链接都交由浏览器处理。 | |
var keyPressed = event.ctrlKey || event.shiftKey || event.altKey || event.metaKey || event.which === 2; | |
var isSameSite = this.protocol === location.protocol && this.hostname === location.hostname && | |
this.port === location.port; | |
if(!keyPressed && isSameSite) { |
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
! 把这个文件放到用户文件夹下 | |
xterm*faceName: Source Code Pro:style=Regular | |
! support chinese | |
xterm*faceNameDoublesize: Droid Sans Fallback:style=Regular | |
xterm*faceSize: 11 | |
xterm*vt100.geometry: 80x23 | |
xterm*loginshell: true | |
! support 256color |
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 -*- | |
""" | |
Install mysql-python on Windows using pip was difficult. | |
This script can help you done the task. | |
Requirements: | |
Python 2.7 | |
pip (setuptools >= 6.0, use `pip install -U setuptools` to upgrade) | |
VCForPython27 (http://www.microsoft.com/en-us/download/details.aspx?id=44266 used to compile mysql-python) |
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 normal() { | |
var color1, color1box, color2, color2box; | |
var boxes = document.querySelectorAll('#box > span'), boxLen = boxes.length; | |
for(var i = 0; i < boxLen; i++) { | |
var box = boxes[i], color = box.style.backgroundColor; | |
if(i == 0) { | |
color1 = color; | |
color1box = box; |
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
value = 1 | |
fn = -> | |
`var value` # 通过这句强制创建一个局部变量 | |
value = 2 |
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 -*- | |
import MySQLdb | |
def get_db(database, user="root", passwd=None, charset='utf8'): | |
return MySQLdb.connect(host="localhost", user=user, passwd=passwd, db=database, charset=charset) | |
def execute(db, sql): | |
cur = db.cursor() |
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
ChildCtrl = function($scope) { | |
$scope.validate = function() { | |
//... | |
} | |
$scope.edit = function(item) { | |
parentValidateFn = $scope.$parent.validate; | |
$scope.$parent.validate = $scope.validate(); // 覆盖父类的方法 | |
$scope.$parent.edit(item); | |
$scope.$parent.validate = parentValidateFn; |