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 python | |
"""Simple HTTP Server With Upload. | |
This module builds on BaseHTTPServer by implementing the standard GET | |
and HEAD requests in a fairly straightforward manner. | |
""" |
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
# Compile nginx standalone without root access | |
mkdir ~/installed | |
mkdir ~/installed/nginx | |
mkdir ~/src | |
cd ~/src | |
# PCRE dependency - we'll compile against this statically | |
wget http://kent.dl.sourceforge.net/sourceforge/pcre/pcre-7.8.tar.gz | |
tar -xzvf pcre-7.8.tar.gz |
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 python | |
# coding=utf-8 | |
from datetime import datetime, timedelta | |
def daterange(start, stop, step_minutes=1): | |
current = start | |
step = timedelta(minutes=step_minutes) | |
if step_minutes > 0: | |
while current < stop: |
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 partial(f) { | |
var args = Array.prototype.slice.call(arguments, 1) | |
return function() { | |
var remainingArgs = Array.prototype.slice.call(arguments) | |
return f.apply(null, args.concat(remainingArgs)) | |
} | |
} | |
var options = { | |
db: { |
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
var mongoose = require('mongoose'); | |
mongoose.connect('mongodb://localhost/test'); | |
var ThingSchema = new mongoose.Schema({ | |
count: Number, | |
version: Number, | |
}); | |
var Thing = mongoose.model('Thing', ThingSchema); | |
var doAdd = function(id, retryTimes){ |
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
var AWS = require('aws-sdk'); | |
AWS.config.loadFromPath('./config.json'); | |
AWS.config.region = 'ap-southeast-1'; | |
//1. download | |
// var s3 = new AWS.S3(); | |
// var file = require('fs').createWriteStream('./docConv.html'); | |
// var params = {Bucket: 'bpctest', Key: 'docConv.html'}; | |
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 qingcloud.iaas | |
from qingcloud.iaas.router_static import RouterStaticFactory | |
access_key = 'xxx' | |
secret_key = 'xxx' | |
conn = qingcloud.iaas.connect_to_zone('gd1', access_key, secret_key) | |
router = 'rtr-xxxxxxxx' | |
# add port forwarding static |
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
var crypto = require('crypto'); | |
var request = require('request'); | |
var setCors = function (MY_ACCOUNT_URL, MY_ACCOUNT_NAME, accountKey) { | |
var MY_CORS_XML = | |
'<?xml version="1.0" encoding="utf-8"?>'+ | |
'<StorageServiceProperties>'+ | |
'<Cors>'+ | |
'<CorsRule>'+ |
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 partial(f) { | |
var args = Array.prototype.slice.call(arguments, 1) | |
return function() { | |
var remainingArgs = Array.prototype.slice.call(arguments) | |
return f.apply(null, args.concat(remainingArgs)) | |
} | |
} |
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
http://stackoverflow.com/questions/5736398/how-to-calculate-the-svg-path-for-an-arc-of-a-circle | |
function polarToCartesian(centerX, centerY, radius, angleInDegrees) { | |
var angleInRadians = angleInDegrees * Math.PI / 180.0; | |
var x = centerX + radius * Math.cos(angleInRadians); | |
var y = centerY + radius * Math.sin(angleInRadians); | |
return [x,y]; | |
} |
OlderNewer