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 | |
| require 'fiber' | |
| def set_interval(millisec, &block) | |
| Fiber.new do | |
| end_time = Time.now.to_i + millisec | |
| loop do | |
| if Time.now.to_i > end_time | |
| end_time = Time.now.to_i + millisec |
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 | |
| require "faraday" | |
| require "json" | |
| LOGIN_EMAIL = '[email protected]' | |
| LOGIN_PASSWORD = 'password here' | |
| def send_req(url, params = {}) | |
| req_params = { |
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
| require 'patron' | |
| require 'rufus-scheduler' | |
| #TODO 异常触发后,将异常的具体内容通过邮件发送至管理员 | |
| module XiaMi | |
| @login_url = 'http://www.xiami.com/web/login' | |
| @index_url = 'http://www.xiami.com/web' | |
| @sign_url = 'http://www.xiami.com/web/checkin/id/' |
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
| # change gopath to current path | |
| export GOPATH=$(pwd) | |
| # create dirs if not exist | |
| mkdir -p bin | |
| mkdir -p src | |
| mkdir -p pkg | |
| # add current bin path to global path | |
| export PATH=$PATH:$GOPATH/bin |
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
| #! /bin/bash | |
| # Get server name source restart.sh sendclient. | |
| servername=${1-'server'} | |
| # Make logs dir if not exist. | |
| mkdir -p logs | |
| # If log file exist, rm and rename it. | |
| if [ -f $servername.log ]; then |
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 express = require('express'); | |
| var app = express(); | |
| var router = express.Router(); | |
| router.get('/', function (req, res) { | |
| res.send('hello world'); | |
| }); | |
| router.get('/reset', function (req, res) { |
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
| $.queue = function(queue) { | |
| var q = queue.sort(function(a, b) { | |
| return a.delay - b.delay; | |
| }), | |
| next, pre = { | |
| delay: 0 | |
| }; | |
| var run = function() { | |
| next = q.shift(); | |
| if (!next) return; |
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 posixpath | |
| from jinja2 import Environment, FileSystemLoader | |
| from tornado.template import BaseLoader | |
| class Template(object): | |
| def __init__(self, template): |
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 functools | |
| import urllib.parse as urllib_parse | |
| from tornado.concurrent import return_future | |
| from tornado.auth import _auth_return_future, AuthError | |
| from tornado import httpclient | |
| from tornado.httputil import url_concat |
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
| class Salesman < Sequel::Model(:crm_resources_salesmen) | |
| include Restfy::Model | |
| allow_method :update, :get, :query, :create | |
| exclude_fields_for [:get, :query], :tenantId | |
| exclude_fields_for_update :tenantId, :groupId | |
| include_fields_for_create :id | |
| one_to_many :logs | |
| one_to_many :tasks |