Skip to content

Instantly share code, notes, and snippets.

@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;
}

Using Dat with a github.io domain

https://i.imgur.com/akOrIOq.png

My personl site is hosted at hashbase.io (link) so that you can access it via dat and https. My canonical dat url is dat://pfrazee.hashbase.io.

Before I used hashbase I used Github Pages, and today it dawned on me that I can have dat://pfrazee.github.io work too. It's pretty simple if you know the dat dns spec.

All I had to do was add /.well-known/dat to my site (click to view). I put the raw dat URL of my site in that file, along with a TTL.

@mafintosh
mafintosh / npm-classic-config.sh
Last active June 21, 2018 17:40
Resets the npm defaults to how they used to be
npm config set loglevel http
npm config set progress false
npm config set package-lock false
npm config set save false
mkdir -p ~/.config/configstore/
printf '{"optOut": true,"lastUpdateCheck": 0}' > ~/.config/configstore/update-notifier-npm.json