Skip to content

Instantly share code, notes, and snippets.

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

Suguru Motegi suguru03

πŸ‘¨β€πŸ’»
\\ TypeScript!! //
View GitHub Profile
const fs = require('fs');
const path = require('path');
const Event = require('events');
const event = new Event();
setImmediate(() => console.log('setImmediate')); // asynchronous 5
fs.lstat(path.join(__dirname, 'test.js'), () => console.log('fs')); // asynchronous 4
setTimeout(() => console.log('setTimeout')); // asynchronous 3
class MyArray extends Array {}
'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.
'use stirct';
const assert = require('assert');
const Promise = require('bluebird');
class Connection {
constructor() {
this._closed = false;
}
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.
@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),
'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 / 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;
@suguru03
suguru03 / users.json
Created July 11, 2016 00:56
This gist is for `made-in-japan`.
{}
@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';