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 _ = require('underscore'); | |
var ObjectID = require('mongodb').ObjectID; | |
var duplicatedIds = []; | |
var lengthOfDuplicatedIds = 10; | |
for (var i = 0; i < lengthOfDuplicatedIds; i++) { | |
duplicatedIds.push(new ObjectID()); | |
} | |
var ArrToTest = []; |
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
// To test with it, run with `curl` | |
// curl -F "photo=@/path/to/your/photo" localhost:3000/api/uploads | |
var express = require('express'); | |
var swagger = require('swagger-jack'); | |
var app = express(); | |
app.use(express.logger('dev')) | |
.use(express.bodyParser()) | |
.use(express.methodOverride()) | |
.use(swagger.generator(app, { |
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
module.exports = { | |
resourcePath: '/orgs', | |
apis: [{ | |
path: '/orgs', | |
operations: [{ | |
httpMethod: 'POST', | |
responseClass: 'void', | |
nickname: 'returnParams', | |
parameters: [{ | |
dataType: 'Org', |
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 Q = require('q'); | |
var util = require('util'); | |
function randomDelayedCall(func) { | |
var delay = Math.floor(Math.random() * (1200 - 100) + 100); | |
setTimeout(func, delay); | |
} | |
function findUser(id, cb) { | |
var err = null; |
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
// 输入 m: 月, d: 天 | |
// 例如 getAstro(5, 1) 返回 `金牛` | |
function getAstro(m, d) { | |
return "魔羯水瓶双鱼牡羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯".substr(m * 2 - (d < "102123444543".charAt(m - 1) - -19) * 2, 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
#!/bin/env ruby | |
# -*- coding: utf-8 -*- | |
class MatrixCalc | |
def initialize(matrix) | |
@matrix = matrix | |
end | |
def input | |
@input ||= traverse |
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
# to memorize the collatz sequence length for a specific number | |
memory = [] | |
Number::collatz = -> | |
if @ % 2 == 0 | |
@ / 2 | |
else | |
3 * @ + 1 | |
Number::collatzSequenceLength = -> |
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
String::reverse = -> | |
size = @length + 1 | |
result = "" | |
while size -= 1 | |
result += @[size - 1] | |
result | |
String::reversable = -> | |
@reverse() == @toString() |
NewerOlder