Skip to content

Instantly share code, notes, and snippets.

@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 
@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.
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 / 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);
#region Instructions
/*
* this as a secret gist:
* https://gist.github.com/dosyago-coder-0/83fd043e9f8e8f06fba95f93a8a1d6a4
*
*/
/*
@o0101
o0101 / classchange.js
Last active July 27, 2018 12:31
'classchange' Event - with watchClassChange and addEventListener('classchange', ...)
"use strict";
{
const config = {attributes: true};
const observer = new MutationObserver(sendEvent);
const listDiff = new WeakMap();
Object.assign(self,{watchClassChange});
function sendEvent(attrChanges) {
attrChanges
"use strict";
{
const version = 'v1';
const service = 'olo-order-analytics';
const DEFAULT = Object.freeze({
TOP_COUNT : 20,
TIMEOUT: 15000
});
@o0101
o0101 / racked.js
Created June 29, 2018 06:39
Better React - AKA REACT FUCK YOU - AKA RACT
/**
In react we do
function Component(props) {
return <h1> Hello, {props.name}</h1>;
}
**/
// in RACT, racked we do
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">