Skip to content

Instantly share code, notes, and snippets.

Alexander Cobleigh cblgh

Block or report user

Report or block cblgh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View img-2-ascii.js
var asciify = require('asciify-image')
var options = {
fit: 'box',
width: process.stdout.columns,
height: process.stdout.rows
asciify('cabal.png', options)
.then(function (asciified) {

cabal-client definitely stores:

  • what channels you have joined
  • for each channel you've joined: what was the latest message you read in that channel
  • last viewed channel

cabal-client probably stores:

  • what cabals you have joined
  • what aliases (human friendly names for cabal:// keys) you have for those cabals
View single-chat.js
var hypercore = require('hypercore')
var pump = require("pump")
var disco = require("discovery-swarm")
var feed = hypercore('./single-chat-feed', {
valueEncoding: 'json'
var swarm = disco()
feed.ready(function () {
console.log("pub", feed.key.toString("hex"))
View cabal


cabal clients

View gist:418c7ea38391ec58a3329c3d75d7b42c
function isValidMessage(msg) {
if (!msg.value.type) msg.value.type = "text/chat"
return msg.value && typeof msg.value === "object"
cblgh / neat-example.js
Created Jul 4, 2018
testing neat-log's re-rendering on resize
View neat-example.js
var neatLog = require('..')
var output = require("diffy/trim")
var log = neatLog(headerView, {fullscreen: true})
log.render() // force an immediate render
function headerView (state) {
return output(`
Hello World!
rows ${process.stdout.rows}
cblgh /
Last active May 1, 2018
make the p2p web with dat's primitives

low level primitives (in ascending abstraction)

  • hypercore works with individual posts in an append-only feed
  • hyperdrive abstracted filestore / works with files
  • hyperdiscovery create p2p swarms for hypercores, hyperdrives, and hyperdbs
  • hyperdb key-value database

higher level abstractions

  • webdb database; basically a document(?) store
  • dat-node built ontop of hypercore & hyperdrive, abstracts a bunch of stuff; less complex but also less flexible
cblgh / alarm.js
Last active Aug 10, 2017
tiny alarm for when you're cooking on your comp
View alarm.js
if (process.argv.length < 3) {
console.error("usage: alarm.js <time (defaults to seconds)> [optionally: minutes|hours|days|years]")
console.error("\tnode alarm.js 2 // trigger alarm in 2 seconds")
console.error("\tnode alarm.js 2 minutes // trigger alarm in 2 minutes")
var time = parseInt(process.argv[2])
var unit = "seconds"
var factor = 1000
cblgh / hyperconnect.js
Last active Jul 10, 2017
connect & read between two hyperdb instances across a network
View hyperconnect.js
var ram = require("random-access-memory") // store remote db in ram. it's nice for testing bc doesnt create a bunch of files
var hyperdiscovery = require("hyperdiscovery")
var hyperdb = require("hyperdb")
var hypercore = require("hypercore")
// local.key is d5d0b189af6b981ab7942c3d71103e9a1cbfa32e203220e830b7a16deac6cc43
var local = hypercore("./local-db", {valueEncoding: "json", sparse: true})
// pass in feeds in same sequence on both machines
var db = hyperdb([
You can’t perform that action at this time.