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
| #! /usr/bin/env python | |
| # -*- coding: utf-8 -*- |
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
| from threading import Thread | |
| import queue | |
| import time | |
| # q是任务队列 | |
| #NUM是并发线程总数 | |
| #JOBS是有多少任务 | |
| q = queue.Queue() | |
| NUM = 2 | |
| JOBS = 10 | |
| #具体的处理函数,负责处理单个任务 |
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
| #!/usr/bin/python | |
| # -*- coding: UTF-8 -*- | |
| import queue as Queue | |
| import threading | |
| import time | |
| exitFlag = 0 | |
| class myThread (threading.Thread): |
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
| public function getTestPjax(Request $request) { | |
| if($request->header('X-PJAX')){ | |
| return "here shoud render html snippts"; | |
| } else { | |
| return "here shoud render full documents"; | |
| } | |
| } |
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
| 'use strict'; | |
| var fn_use_rest = function(...rest){console.log(rest);} | |
| var fn_use_args = function(){console.log(arguments);} | |
| fn_use_rest(1,2,3,a=4,b=5); | |
| /* | |
| * OUTPUT | |
| * Array [1,2,3,4,5] |
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 load_apps(apps): | |
| import importlib | |
| GlobalUrls = [] | |
| for app in apps: | |
| module = importlib.import_module('app.{AppName}.urls'.format(AppName=app)) | |
| GlobalUrls += getattr(module,'urls') | |
| return GlobalUrls |
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
| $allControllers = []; | |
| function scanControllers($path, &$result) { | |
| $dirs = scandir($path); | |
| foreach($dirs as $dir){ | |
| if ($dir{0} == '.') { //todo: 适配linux下.开头的隐藏文件 | |
| continue; | |
| } | |
| if (substr($dir, -4) == '.php') { | |
| $result[] = $path. DIRECTORY_SEPARATOR .$dir; |
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
| const path = require('path') | |
| const ExtractTextPlugin = require("extract-text-webpack-plugin") | |
| const prod = process.argv.indexOf('-p') !== -1 | |
| const theme = 'geil' | |
| const ProjectRoot = path.dirname(path.dirname(path.dirname(__dirname))) | |
| const TargetWebRoot = path.join(ProjectRoot, 'blog', 'web', 'themes', theme) | |
| const ResourceRoot = path.join(__dirname, 'resources') |
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
| var http = require('http') | |
| function callAPI() { | |
| return new Promise((resolve, reject) => { | |
| http.get('http://www.jb51.net', (res) => { | |
| resolve(res.statusCode) | |
| }) | |
| }) | |
| } |
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
| var diff = $(this).data('time')*1000 - Date.parse(new Date()); | |
| if (diff < 0 ) { $(this).text('竞猜结束');return; } | |
| var sec = diff/1000%60; | |
| var min = Math.floor(diff%(24*3600*1000)%(3600*1000)/(60*1000)) || ''; | |
| var hour = Math.floor(diff%(24*3600*1000)/(3600*1000)) || ''; | |
| var day = Math.floor(diff/(24*3600*1000)) || ''; | |
| day = day.length === 0 ? '' : day + '天'; | |
| hour = hour.length === 0 ? '' : hour + '小时'; | |
| min = min.length === 0 ? '' : min + '分钟'; | |
| sec = sec.length === 0 ? '' : sec + '秒'; |
OlderNewer