Skip to content

Instantly share code, notes, and snippets.

@yusefnapora
yusefnapora / restart-xcode.sh
Created April 7, 2015 00:03
Restart Xcode script
#!/bin/bash
xcode_version="Xcode-beta"
killall Xcode 2> /dev/null
sleep 1
open "/Applications/$xcode_version.app"
@yusefnapora
yusefnapora / onename.txt
Created November 30, 2015 15:10
onename verification
Verifying that +sefnap is my blockchain ID. https://onename.com/sefnap
#!/bin/bash
type jq >/dev/null 2>&1 || { echo >&2 "Please install jq: https://stedolan.github.io/jq/"; exit 1; }
type curl >/dev/null 2>&1 || { echo >&2 "Please install curl"; exit 1; }
if [ "$2" = "--local-ipfs" ] && (type ipfs >/dev/null 2>&1); then
USE_LOCAL_IPFS=1
else
USE_LOCAL_IPFS=0
fi
@yusefnapora
yusefnapora / example.scala
Created March 22, 2016 22:07
Hashable marshalling
// The idea here is that case classes that extend `Hashable` will be converted to
// a Json AST using json4s, then written as canonical CBOR & hashed with SHA-256
//
// The actual hashing happens in `MultiHash.forHashable`, which can fail if the
// Json conversion fails.
//
// I don't think this custom marshaller trick will work for signatures, though,
// because it needs the signing key as an input, which wouldn't be available to
// the gremlin-scala marshaller.
//
@yusefnapora
yusefnapora / transactor-interface-draft.markdown
Last active April 21, 2016 21:38
transactor interface notes

Transactor interfaces

The Transactor peer nodes are responsible for writing data to the system and ensuring consistency.

Transactors have two main client-facing interfaces:

  • writing data to persistent storage (e.g. IPFS) on behalf of clients
  • informing clients of changes to the Journal when updates are made
@yusefnapora
yusefnapora / applicative-future-cats.scala
Created May 13, 2016 14:41
Applicative instance for scala Future using cats
object Foo {
// based on this scalaz version: https://gist.github.com/Fristi/e7139a89e2c66d455e97
implicit def applicativeFuture(implicit executionContext: ExecutionContext)
= new Applicative[Future] {
override def pure[A](x: A): Future[A] = Future.successful(x)
override def ap[A, B](ff: Future[(A) => B])(fa: Future[A]): Future[B] =
ff.flatMap(fa.map(_))
@yusefnapora
yusefnapora / setup.scala
Last active June 8, 2016 18:38
setup local dynamo for mediachain
import com.amazonaws.auth.BasicAWSCredentials
val awscreds = new BasicAWSCredentials("", "")
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient
val dynamo = new AmazonDynamoDBClient(awscreds).withEndpoint("http://localhost:8000").asInstanceOf[AmazonDynamoDBClient]
import scala.collection.JavaConversions._
import com.amazonaws.services.dynamodbv2.model._
val baseTable = "Mediachain"

Keybase proof

I hereby claim:

  • I am yusefnapora on github.
  • I am yusef (https://keybase.io/yusef) on keybase.
  • I have a public key ASDpxm7pgDUDKs8tbHQ4jFHkm-fb4YaPhy0bWASLQk2WBwo

To claim this, I am signing this object:

$ virtualenv venv
$ source venv/bin/activate
(venv) $ pip install -U pip
(venv) $ pip install mediachain-client
(venv) $ mediachain get QmVwwiMVDH7umVSd3vdbwGS3WmFX2axhJCTpbfU4LMPcE8
{
"metaSource": {
"@link": "Qmcbo67Ycv6rCREhQYoYeGJzgAJiCZDfyEdtHqdbmTsv6T"
},
"meta": {
@yusefnapora
yusefnapora / mediachain-next-api.md
Created August 26, 2016 19:33
high-level api design notes for mediachain phase 2 design

mediachain.next api notes

Everything here is in flux and subject to change; this is just a sketch. The idea is to give an overview of the high-level api surface of an "online" node, that is, one that actively contributes to the network and is expected to remain connected to the network.

All the code examples below are in javascript, with flow-style annotations for return types.

Peer ids & local state

A peer has a unique id, which is the hash of their public key. They may also have a collection of certificates, signed by moderators of the namespaces they're authorized to participate in.

The peer-local state includes the peer's id, certificate store, private key, etc. It also includes the index of connected peers, which allows us to route operations to peers with the correct roles.