Skip to content

Instantly share code, notes, and snippets.

View serapath's full-sized avatar
💔
Github was acquired

Alexander Praetorius serapath

💔
Github was acquired
View GitHub Profile
@serapath
serapath / ballot.sol
Created May 3, 2018 00:29
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.23+commit.124ca40d.js&optimize=false&gist=
pragma solidity ^0.4.0;
contract Ballot {
struct Voter {
uint weight;
bool voted;
uint8 vote;
address delegate;
}
struct Proposal {
@serapath
serapath / filesystem.md
Last active September 17, 2022 03:43
JSON file system

So what about leaning on require('fs').stats method and the .stats property

// "" (empty string) as a property key is valid json
var fs = {
  "a" : {
    // maybe not ALL of those properties make sense in a "json file system",
    // so only the meaningful ones should exist
    "/type": "directory",
      // is one of ['file', 'directory', 'blockdevice' , 'characterdevice', 'symlink', 'FIFO', 'socket']
    "/dev": 2114,
@serapath
serapath / codepen.md
Last active November 19, 2019 17:02
A synchronous `require` function for the browser that downloads and caches modules from npm - just copy & paste it to the dev tools javascript console

use require in a codepen

  1. click on the little icon Open JS Settings on the JavaScript editor pane
  2. Then add the following link under Add External Javascript
https://cdn.rawgit.com/serapath/e2b55cab315e60fbbffea7b43acd8749/raw/29aac6cb7361fb9d8467adee4e0d112961395a95/require.js
  1. Press Save & Close and start using the require(...) in your JavaScript code on codepen
@serapath
serapath / args.js
Created September 14, 2016 23:36
cli args
var r={};'hello x=5 hey="cool"'.replace(/([^=\s]+)(?:\s*=\s*(?:"([^"]*?)"|\'([^']*?)\'|(\S*)))?/g,function(_,k,d,s,b){r[k]=d||s||b||true});r
@serapath
serapath / index.js
Created August 16, 2016 17:51
requirebin sketch
setInterval(function(xhr, randCol) {
var color=(color=randCol().hexString()).slice(1,color.length)
xhr({url:'http://192.168.2.4/change_color',method:'POST',data:'color='+color})
},3000, require('minixhr'), require('random-color'))
@serapath
serapath / index.js
Last active July 3, 2016 18:39
requirebin sketch
require('dom-console')({console:true,initAction:'minimize'})
/******************************************************************************
HELPER
******************************************************************************/
var apply=J=>J.forEach(b=>b.forEach(e=>e[0][e[1]]?e[0][e[1]]+=e[2]:e[0][e[1]]=e[2]))
var log=E=>console.log(E)
/******************************************************************************
"VALUE EQUATIONS"
******************************************************************************/
CONTRACT = {
@serapath
serapath / ycomb.js
Created May 21, 2016 16:55
y combinator
function Y (F) {
function fn (x) {
return F(function (y) { return x(x)(y) })
}
return F(function (y) { return fn(fn)(y) })
}
function FactGen (fact) {
return function (n) {
return (n == 0) ? 1 : (n*fact(n-1))
@serapath
serapath / keyboardlayout.js
Created February 5, 2016 20:32
User needs to type a unique pattern of keys
// <html>
// <head>
// <meta charset="UTF-8">
// </head>
// <body>
// <script src="asdf.js"></script>
// </body>
// </html>
var charOE = 'ö'.charCodeAt(0)
var charSEMICOLON = ';'.charCodeAt(0)
@serapath
serapath / Comments in Source Files
Last active February 1, 2016 00:16
Comments in Source Files
/*
Make use of:
@NOTE
@REVIEW
@HACK
@IDEA
@XXX
@FIXME
@TODO
@serapath
serapath / index.js
Last active December 20, 2015 07:52
Virtual Level Tracker
/********************************************************************
COMPONENT - ./MyThunk.js
********************************************************************/
// module.exports = MyThunk
function Hook (db, component, tracks, TEMP) {
this.db = db
this.component = component
this.tracks = tracks
this.TEMP = TEMP
this.untrack = []