Skip to content

Instantly share code, notes, and snippets.

View suguru03's full-sized avatar
πŸ‘¨β€πŸ’»
\\ TypeScript!! //

Suguru Motegi suguru03

πŸ‘¨β€πŸ’»
\\ TypeScript!! //
View GitHub Profile
function combinationLoop(list, choose, callback) {
(function loop(result, nest, index, length) {
while (index <= length + nest - choose) {
(nest === 0 ? (result = []) : result)[nest] = list[index++];
if (nest < choose - 1) {
loop(result, nest + 1, index, length);
} else {
callback(result.concat()); // 犢況に応じて不要
}
}
/**
* How to use.
* 1. access to http://suguru03.github.io/yasuda-benchmark/
* 2. gist("https://gist.github.com/suguru03/b35074cd74e132ffdd7cb10940b3b873").execute();
*/
var root = this;
var setup = function() {
this.array1 = Array(100);
this.array2 = Array(100);
@suguru03
suguru03 / createFunction.js
Last active June 3, 2016 17:43
create function with name
function createFunc(name, args, fstr) {
var arr = [name, args, fstr];
var str = 'return function %s(%s) %s;';
str = str.replace(/%s/g, function() {
return arr.shift();
});
return new Function(str)();
}
var name = 'test';
@suguru03
suguru03 / users.json
Created July 11, 2016 00:56
This gist is for `made-in-japan`.
{}
@suguru03
suguru03 / server.js
Created September 16, 2016 16:24
```npm i express body-parser`
'use strict';
const path = require('path');
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const port = process.env.PORT || 8000;
'use strict';
const fs = require('fs');
const path = require('path');
const filepath = path.resolve(__dirname, 'sample.js');
const code = fs.readFileSync(filepath, 'utf8');
const { Agent } = require('vm-agent');
const result1 = new Agent(code).run().getInnerVariable();
@suguru03
suguru03 / starcounter.js
Created May 22, 2017 02:06 — forked from yyx990803/starcounter.js
Count your total stars!
var https = require('https'),
user = process.argv[2],
opts = parseOpts(process.argv.slice(3))
request('/users/' + user, function (res) {
if (!res.public_repos) {
console.log(res.message)
return
}
var pages = Math.ceil(res.public_repos / 100),
const _ = require('lodash');
const Aigle = require('aigle');
Aigle.mixin(_);
execute();
/*
* If `Aigle` has the same function names as `Lodash` ones, they will be ignored.
* All of them have the same functionality and are optimized for asynchronous.
'use stirct';
const assert = require('assert');
const Promise = require('bluebird');
class Connection {
constructor() {
this._closed = false;
}
'use strict';
/* native Promise is used as default.
* You can try
* ```
* node --expose_gc memory_leak_test.js
* ```
*
* I'm just wondering if `expose_gc` has something problem.
* When the code is executed a lot of times, execution speed willb be slow down.