Skip to content

Instantly share code, notes, and snippets.

@balupton
balupton / README.md
Last active June 5, 2019 10:26
Summary of the Node.js Board controversy from what I can gather
@tj
tj / snippets.coffee
Last active September 1, 2018 19:01
Atom snippets for Go
'.source.go':
'Options':
'prefix': 'options'
'body': '''
// Option function.
type Option func(*$1)
// New with the given options.
func New(options ...Option) *$1 {
@alexellis
alexellis / k8s-pi.md
Last active June 28, 2025 05:44
K8s on Raspbian
@creationix
creationix / tree-on-list.js
Last active December 28, 2018 13:50
a hyperdrive inspired data structure for storing FS changes to a log of events.
/*
0 - [foo] [[0][]] time - Add empty folder /foo
1 - [foo,hello] [[1][1]] time meta - Add file /foo/hello
2 - [foo,goodbye] [[2][1,2]] time meta - Add file /foo/goodbye
3 - [foo,man] [[3][1,2,3][]] time - Add empty folder /foo/man
4 - [bar,baz] [[3,4][4]] time meta - Add file /bar/baz
5 - [bar,bit] [[3,5][4,5]] time meta - Add file /bar/bit
6 - [foo,hello] [[5,6][2,3]] time - Delete /foo/hello
@max-mapper
max-mapper / index.js
Last active August 9, 2017 02:12
crossref paginated works metadata streaming archiver
var request = require('request')
var base = 'https://api.crossref.org/works?filter=type:dataset&rows=1000'
doNext()
function doNext (cursor) {
if (!cursor) cursor = '*'
var url = base + '&cursor=' + cursor
console.error('GET', url)
@creationix
creationix / idb-dat-storage.js
Created August 8, 2017 22:40
A simple abstract-random-access implementation using indexed DB that takes advantage of hypercore's behavior or consistent boundaries/offsets.
/* eslint-env browser */
var Buffer = require('buffer').Buffer
var name = 'dat'
function withStore (type, block, callback) {
var req = indexedDB.open(name + '-db', 1)
req.onerror = () => callback(req.error)
req.onupgradeneeded = () => req.result.createObjectStore(name)
req.onsuccess = () => {
var neat = require('neat-log')
var output = require('neat-log/output')
var progress = require('progress-string')
var crypto = require('crypto')
var hypercore = require('hypercore')
var hyperdiscovery = require('hyperdiscovery')
var feed = hypercore('data', process.argv[2], {valueEncoding: 'json'})

Can we create a smart contract VM on nodejs using Dat?

Ethereum is a trustless network of VMs which run smart contracts submitted by users. It uses proof-of-work to synchronize state across the network, and has every node execute the contracts in order to verify the state's validity. Each transaction is stored in the blockchain for replayability. Read more about it here.

Ethereum's "trustless network" model has some disadvantages:

  • Transaction processing is slow - it maxes at roughly 25tx/s right now for all contracts combined.
  • Every transaction costs money to execute.
  • The entire blockchain state must be shared across the computing network.
  • No private transactions.
@WebReflection
WebReflection / hyper-element.js
Created July 27, 2017 15:31
One possible way to simplify hyperHTML components.
const borrowedState = require('flatstate').setState;
class HyperElement extends HTMLElement {
constructor(...args) {
super(...args);
this.html = hyperHTML.bind(this);
}
render() {}
@ValentinFunk
ValentinFunk / NetlifyServerPushPlugin.js
Last active May 4, 2024 04:24
Webpack - Generate Netlify HTTP2 Server Push _headers File when using the HtmlWebpackPlugin
/**
* Generate a Netlify HTTP2 Server Push configuration.
*
* Options:
* - headersFile {string} path to the _headers file that should be generated (relative to your output dir)
*/
function NetlifyServerPushPlugin(options) {
this.options = options;
}