Skip to content

Instantly share code, notes, and snippets.

View o0101's full-sized avatar
🏖️
Netscaping

Cris o0101

🏖️
Netscaping
View GitHub Profile
@o0101
o0101 / IdealBrutal.js
Last active August 28, 2020 10:29
Ideal Brutal
// server
async function showAuthorInfobox({target}, id) {
const boxData = await getInfoBox(id);
AuthorInfobox(boxData).to(target, 'hovercard');
}
app.get('/story/:id', async (req,res,next) => {
const article = await getArticle(req.params.id);
function R (parts, ...vals) {
const handlers = {};
let hid, lastNewTagIndex, lastTagName, str = '';
parts = [...parts];
vals = vals.map(parseValue);
while (parts.length > 1) {
let part = parts.shift(),
attrNameMatches = part.match(LAST_ATTR_NAME),
@o0101
o0101 / gist:535c6b132966ad304ccf32340ba67e91
Created August 4, 2018 12:18
Test to see how SSR might work.
with SSR without JS
we need a server endpoint for each view function
the endpoint also specifies an ID if the thing is keyed (so it can look up the data)
and it can take POST data
in order to "send" the data
there must be hidden form fields for anything that doesn't have a real form field.
there will no doubt be restrictions in this type of app.
SSR is pretty easy if you just want to do first render and then load everything up.
@o0101
o0101 / readme.md
Created August 16, 2018 13:54 — forked from flbuddymooreiv/readme.md
erlang + rebar + cowboy Hello World

This is the process of setting up erlang, rebar3, and cowboy for a Hello World, starting with a clean Debian 8 install.

Update apt and install deps:

root@046edcaea45a:~# apt-get update
root@046edcaea45a:~# apt-get install erlang erlang-dev gcc
root@046edcaea45a:~# wget https://s3.amazonaws.com/rebar3/rebar3
root@046edcaea45a:~# mkdir ~/bin/
root@046edcaea45a:~# mv rebar3 ~/bin/
root@046edcaea45a:~# chmod +x ~/bin/rebar3 
#include <map>
#include <limits>
template<typename K, typename V>
class interval_map {
std::map<K,V> m_map;
public:
// constructor associates whole range of K with val by inserting (K_min, val)
// into the map
@o0101
o0101 / pseudo_elements.md
Created September 6, 2018 14:33 — forked from p3t3r67x0/pseudo_elements.md
A CSS pseudo-element is used to style specified parts of an element. In some cases you can style native HTML controls with vendor specific pseudo-elements. Here you will find an list of cross browser specific pseudo-element selectors.

Styling native elements

Native HTML controls are a challenge to style. You can style any element in the web platform that uses Shadow DOM with a pseudo element ::pseudo-element or the /deep/ path selector.

video::webkit-media-controls-timeline {
  background-color: lime;
}

video /deep/ input[type=range] {
// generate a random unique code that has ~ 51 bits of entropy
function randid({int:int=false}={}) {
const randInt = Math.round((Math.random()*performance.now()*(+ new Date))/1000);
if ( !! int ) return randInt;
else return randInt.toString(36);
}
// generate a sequence of keys (that throws at MAX_SAFE_INTEGER, roughly ~53 bits)
function *nextkey(prefix = '') {
let count = 1;
@o0101
o0101 / state.md
Last active August 28, 2020 10:29

Ideas:

// state is just objects, but what are changes to state?
// probably also just objects
// but what is the easiest way to "change state"
// let's look at the different types of state
// an object is just a map of keys to values
// a key is a string (without loss of generality)

// Make an "icon font" / CSS sheet that I can use for icons, and make it the ONLY icons I use in all my apps // and use "the symbolism"

Owl - 🦉

Hexagon - ⬢

Circle star - ۞

Symbol 1 - ࿃

Symbol 2 - ࿋

run();
async function run() {
const orders = await getOrders('http://files.olo.com/pizzas.json');
const orderCounts = countOrders(orders);
const topOrders = sortCounts(orderCounts).slice(0,20);
console.log(JSON.stringify({topOrders},null,2));
}
async function getOrders(url) {