Skip to content

Instantly share code, notes, and snippets.

const dc = require("dosycrypt");
const page = ({message:message = ''}={}) => `
<title>DOSYCRYPT</title>
<meta name=viewport content="width=device-width, initial-scale=1">
<style>
:root, body, input, textarea, button {
background: orange; color: white;
}
</style>
@o0101
o0101 / kvdb.js
Last active October 26, 2017 10:38
key-value-datastore
/** see a live demo here: https://runkit.io/dosyago-coder-0/kvdb/branches/master **/
const express = require("express");
const bodyParser = require("body-parser");
const db = new Map();
const page = () => `
<!DOCTYPE html>
<meta charset=utf-8>
@o0101
o0101 / sketch.js
Last active October 17, 2017 12:00
Text matching in adversarial conditions.
/**
Idea is we want to "attach" something ( annotation, edit, image, link, whatever )
to a particular piece of text that is not necessarily defined by an element.
In other words, some free form text. Whether this text comes from HTML, or a text file
is unimportant. The point is to find this attachment point even when:
- the order of paragraphs is altered
- the order of sentences in a paragraph is altered
- the order of words in a sentence is altered
And we would like to still find the attachment point with high probability when:
@o0101
o0101 / cracklepop.js
Created October 14, 2017 13:14
Crackle Pop
// javascript (tested in Chrome 61)
// also here: https://runkit.com/dosyago-coder-0/cracklepop
(new Array(8)).join('///Crackle//Pop/Crackle///Crackle/Pop//Crackle///CracklePop')
.split(/\//g).slice(0,101).forEach((print,number) => number > 0 ? console.log(`${number}: ${print}`) : '');
@o0101
o0101 / codegolf.md
Created September 28, 2017 09:48 — forked from xem/codegolf.md
JS code golfing

codegolf JS

Mini projects by Maxime Euzière (xem), subzey, Martin Kleppe (aemkei), Mathieu Henri (p01), Litterallylara, Tommy Hodgins (innovati), Veu(beke), Anders Kaare, Keith Clark, Addy Osmani, bburky, rlauck, cmoreau, maettig, thiemowmde, ilesinge, adlq, solinca, xen_the,...

(For more info and other projects, visit http://xem.github.io)

(Official Slack room: http://jsgolf.club / join us on http://register.jsgolf.club)

@o0101
o0101 / wow.js
Created September 28, 2017 09:45
Micro Spread Sheet
// check this: http://jsfiddle.net/ondras/hYfN3/
@o0101
o0101 / neucomponents.js
Last active September 24, 2017 04:25
It all sucks. Time to make it better.
/**
So dosyhil gives good components on the server.
What about the client?
**/
// example
const components = {};
Object.assign( self, { components } );
def`
@o0101
o0101 / index.html
Created September 23, 2017 18:15 — forked from anonymous/index.html
Bookmarklet // source https://jsbin.com/nosefuduju
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Bookmarklet</title>
</head>
<body style="max-width:700px; margin:0 auto;">
<p>Here is the bookmarklet:
<a href="javascript:(function()%7B(function()%20%7Bconst%20req%20%3D%20new%20XMLHttpRequest()%3Bconst%20key%20%3D%20'AIzaSyAUYMRSUW3BAZLhSTbB1poQuQ4xaqt2C4c'%3Breq.open('POST'%2C%20'https%3A%2F%2Fwww.googleapis.com%2Furlshortener%2Fv1%2Furl%3Fkey%3D'%2Bkey)%3Breq.setRequestHeader(%22Content-Type%22%2C%20%22application%2Fjson%22)%3Breq.responseType%3D%22json%22%3Breq.send(JSON.stringify(%7BlongUrl%3Alocation.href%7D))%3Bconst%20text%20%3D%20document.createElement('textarea')%3Blet%20result%3BsetTimeout(%20()%20%3D%3E%20(document.execCommand('copy')%2Ctext.remove())%2C%20700%20)%3Breq.onreadystatechange%20%3D%20()%20%3D%3E%20%7Bif%20(%20req.status%20%3D%3D%20200%20%26%26%20req.readyState%20%3D%3D%204%20)%20%7Bdocument.body.appendChild(text)%3Btext.value%20%3D%20req.response.id%3Btext.se
/**
Example of component api idea
**/
component1.api = {
add_sel()
del_sel()
generalize()
@o0101
o0101 / two.js
Created September 17, 2017 11:22
// more 5 line functions
function project( obj, ...slots ) {
slots = new Set(slots);
const pslots = Object.keys( obj ).filter( k => slots.has(k) );
return pslots.reduce( (p,k) => (k.includes('.') ? p[k] = resolve(obj,k) : p[k]=obj[k],p), {});
}
function resolve( obj, path ) {
// FIXME: if key == '.' this will break. :)