Skip to content

Instantly share code, notes, and snippets.

@rewonc
rewonc / app.js
Last active January 23, 2017 19:59
Authenticate a user with angularfire, save to firebase, and make available to controllers with promise
/*
This file is a brief example of how to use angularfire to authenticate a user, save that user's public profile to firebase, then
ensure that both the authenticated and public user are available in your controllers.
The route configuration uses angular-ui-router: https://github.com/angular-ui/ui-router
*/

Resilience — RES with built-in dividend pathways and swarm redistribution, for decentralized basic income

The idea to use the global financial network of daily transactions, and to link these transactions together into a web, is a bit similar to Tim Berners Lee's idea to link all documents on the internet together with the Hypertext Transfer Protocol (HTTP), which gave us the world wide web. When Tim Berners Lee had the idea for the world wide web in the 80s, there were already documents on the internet. He did not have to invent the internet, and his contribution was instead that he saw a way to harness the information on the internet in a new way.

The same goes for the Resilience protocol. The world is electrified with millions, or billions, of financial transactions happening every single day. The global financial network is part of our infrastructure already. What Resilience aims to

anonymous
anonymous / Teikhos.js
Created March 14, 2018 16:56
Generate proof-of-public-key, for use with the Teikhos authentication method
const ethUtils = require('ethereumjs-util');
const EthCrypto = require('eth-crypto');
const xor = require('buffer-xor')
const keccak = require('keccakjs')
const identity = EthCrypto.createIdentity();
const privateKey = new Buffer(identity.privateKey.slice(2), 'hex')
console.log("privateKey:")

Proof-of-power, using a swarm to select miners through majority consensus

Johan Nygren, Bitnation, 2017

In 2008, Craig Wright published the Bitcoin whitepaper, and the idea to use proof-of-work as a trusted authority, provably distributed. This Nakamoto consensus allowed the Bitcoin ledger to extend itself in a way that was resilient to censorship as well as to servers being shut down, and in a way where as the security of the network grew, the number of users and therefore the value of the network also grew following Metcalfe´s Law. Bitcoin was the beginning of what can be broadly defined as “network-states”, successors to the nation-state consensus.

The next generation of a distributed authority for a “network-state” was developed in 2014 by Vlad Zamfir, with the Casper protocol and “consensus-by-bet”, an evolution of the idea of proof-of-stake. With consensus-by-bet, validators would stake their capital in a betting game, and converge on a block, in a way that was also resilient to being shut down,

@chrisdone
chrisdone / Origami.hs
Last active July 23, 2018 00:24
Origamic fold
-- | Fold over the input, folding left or right depending on the element.
origami :: (s -> l -> s) -> (r -> s -> s) -> s -> [Either l r] -> s
origami _ _ nil [] = nil
origami fl fr nil (x:xs) =
case x of
Left l -> origami fl fr (fl nil l) xs
Right r -> fr r (origami fl fr nil xs)
@NicolasT
NicolasT / Primes.hs
Created August 1, 2011 14:14
Simple Haskell implementation of the Paillier homomorphic encryption scheme
{-# LANGUAGE BangPatterns, ScopedTypeVariables #-}
-- Stuff taken from the RSA module for now
module Primes where
import Data.Bits
import Data.Int
import Data.Word
import Data.ByteString.Lazy (ByteString)
@katowulf
katowulf / 1_using_queries.js
Last active April 24, 2023 07:14
Methods to search for user accounts by email address in Firebase
/***************************************************
* Simple and elegant, no code complexity
* Disadvantages: Requires warming all data into server memory (could take a long time for MBs of data or millions of records)
* (This disadvantage should go away as we add optimizations to the core product)
***************************************************/
var fb = firebase.database.ref();
/**
* @param {string} emailAddress
@jfairbank
jfairbank / fibonacci-generator.js
Last active December 4, 2023 12:23
Fibonacci ES6 Generator
function *fibonacci(n) {
const infinite = !n && n !== 0;
let current = 0;
let next = 1;
while (infinite || n--) {
yield current;
[current, next] = [next, current + next];
}
}
@sarthology
sarthology / regexCheatsheet.js
Created January 10, 2019 07:54
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@stephantabor
stephantabor / bb.js
Last active January 6, 2024 04:18
Bluebird .each vs .mapSeries vs .map
var Promise = require('bluebird');
var funcs = Promise.resolve([500, 100, 400, 200].map((n) => makeWait(n)));
funcs
.each(iterator) // logs: 500, 100, 400, 200
.then(console.log) // logs: [ [Function], [Function], [Function], [Function] ]
funcs
.mapSeries(iterator) // logs: 500, 100, 400, 200