Skip to content

Instantly share code, notes, and snippets.

@mmis1000
mmis1000 / brainfuck intepreter.js
Created April 27, 2018 16:05
write brainfuck intepreter with recursion
const recurr = (fn => fn(
(f => f(f))
(self =>
x =>
fn(self(self))(x)
)
))
recurr(
main =>
var a;
var max = 10;
console.log('start')
for (a = 0; a < max; a++) {
console.log(a)
}
console.log('exit')
//
@mmis1000
mmis1000 / webpack.config.js
Last active April 24, 2018 04:23
Webpack plugin to rewrite non-existed .js path to .ts
const path = require('path');
const fs = require("fs");
class RewritePlugin {
/**
* @private
* @typedef {Object} Request
* @prop {string} request
* @prop {string} context
*/
@mmis1000
mmis1000 / client.js
Last active April 13, 2018 13:10
test
var { execFileSync } = require('child_process');
var dnode = require('dnode');
var d = dnode.connect(5004);
const syncRequest = (q)=>{
return JSON.parse(
execFileSync(
'node',
@mmis1000
mmis1000 / index.js
Last active April 8, 2018 08:12
screenshot.js
const screenshot = require('screenshot-desktop');
const telegram = require('telegram-bot-api');
const fs = require('fs-extra')
const processWindows = require("node-process-windows");
const winctl = require('@mmis1000/winctl');
const path = require("path");
const api = new telegram({
token: '532873658:AAF9AzzzzzzzzzzzzzaqjxfJ2DowE',
updates: {
@mmis1000
mmis1000 / flatMap.js
Created March 20, 2018 19:47
zero variable, zero function call flatmap
// recursive
(fn=>fn(
(f=>f(f))
(
self=>
x=>
fn(self(self))(x)
)
))
(
function c(m, n) {
var val = 1
for (let temp = m; temp > m - n; temp--) {
val = val * temp / (temp - m + n)
}
return val;
}
function p(w, h) {
module.exports = function (bridge) {
bridge.allOnce(['config', 'makeLog', 'URLHandlers', 'queue', 'doQueueSong', 'songList', 'addToSongList', 'doTTS', 'opus_stream', 'volume'],
function (config, makeLog, URLHandlers, queue, doQueueSong, songList, addToSongList, doTTS, opus_stream, volume) {
if (!config.discord.token) {
console.warn('[Discord] Missing bot token! The Discord module will not load.');
return;
}
const Discord = require('discord.js');
const urlRegex = require('url-regex');
@mmis1000
mmis1000 / function-overload.js
Created December 6, 2016 15:45
function overload and type checking for javascript
/* validator {
* match: boolean function(any value)
* description: string
* }
*/
function makeValidator(type) {
var validator, subValidator, subValidatorMap;
var emptyValidator = {
match : function () {return true},
const fs = require('fs-extra')
const telegram = require('telegram-bot-api');
const find = require('find');
const crypto = require('crypto');
var savePath = require('path').resolve(process.cwd(), '.rand_img_bot_.data.json')
class Storage {
constructor(path) {
this.path = path