Skip to content

Instantly share code, notes, and snippets.

View greenlikeorange's full-sized avatar
🎯
Focusing

nonce greenlikeorange

🎯
Focusing
  • Base Technology
  • Yangon, Myanmar
View GitHub Profile
@greenlikeorange
greenlikeorange / optimizer.js
Last active October 20, 2020 13:20
Async function optimiser
const EventEmitter = require('events');
class Optimizer extends EventEmitter {
// state
#inprogress = {};
constructor(fn, maxConcurrentCall = 10) {
super();
this.setMaxListeners(maxConcurrentCall);
return (tag) => {
@greenlikeorange
greenlikeorange / README.txt
Last active March 6, 2020 11:46
Lazy Clone using Proxy
Just created! Very limitted usage.
TODO:
- `enumerate`
- `ownKeys`
- `has`
@greenlikeorange
greenlikeorange / README.md
Last active October 26, 2020 05:58
Some of my array methods

NOTE: This is my experiment, you can use Rx or something better than mine one XD

At the time, I need an array method act like array.forEach methods I thinking about to create the first function in this gist.

Here I describe example ways to use these functions in code. (I'm so boring to write a story :3)

Exmaple 1: When you to update a list item one by one asynchronously. you may use asyncForEach

async function magicSpell() {
  const birdIds = [1,2,3,4,5,6,7,8,9,10]; // list of items
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
body {
padding: 25px;
}
@greenlikeorange
greenlikeorange / DevCon2019Schedule.json
Created December 20, 2019 11:07
Developer Conference 2019 Schedule
{}
@greenlikeorange
greenlikeorange / MyanmarPhoneNumberUtil.js
Created December 2, 2019 11:35
Myanmar Phone Number Util
const RULES_BY_OPRATORS = {
MPT_GSM: [
'20{5}',
'21{5}',
'22{5}',
'23{5}',
'24{5}',
'40{7}',
'41{6}',
'42{7}',
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<button id = "find-me">Show my location</button><br/>
<p id = "status"></p>
@greenlikeorange
greenlikeorange / loginattempt.js
Created October 23, 2018 11:43
Login attempt
const MAX_TRY_COUNT = 5;
const TIME_OF_DENINE = 10 * 60 * 1000; // 10 minutes
const loginAttempts = {};
function createLoginAttemptIfNotExits(username) {
if (loginAttempts[username]) {
loginAttempts[username] = { try: 0, lastTry: 0 };
}
}
@greenlikeorange
greenlikeorange / example.js
Last active August 22, 2016 13:22
Add ".also" Langauge chain to chai.expect to make test with multi scenarios Promise test case;
'use strict';
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
const expectChain = require('./expectChain');
chai.use(chaiAsPromised);
chai.use(expectChain);
const expect = chai.expect;
@greenlikeorange
greenlikeorange / hook.js
Created October 20, 2015 07:40
Automatic deployement -- Nodejs, Pm2 and github
var http = require("http");
var exec = require("child_process").exec;
var createHandler = require("github-webhook-handler");
var handler = createHandler({ path: "/", secret: "လျှို့ဝှက်ချက်"});
http.createServer(function(req, res) {
handler(req, res, function (err) {
res.statusCode = 404;
res.end("no such location");
});