Skip to content

Instantly share code, notes, and snippets.

View parkan's full-sized avatar

Arkadiy Kukarkin parkan

View GitHub Profile
@parkan
parkan / dc-aliases-zsh
Last active August 29, 2015 14:25
docker-compose aliases
b2d-shellinit(){
[ -z "$DOCKER_HOST" ] && $(boot2docker shellinit)
}
alias dc='b2d-shellinit; docker-compose'
alias dcr='b2d-shellinit; docker-compose run'
alias dcr-heroku='b2d-shellinit; docker-compose run `heroku config -a XXX-production | tail +2 | tr -s " " | sed -E "s/^([^ ]+): (.+)/-e \1=\2/" | tr "\\n" " "` api rails c'
alias dcr-heroku-staging='b2d-shellinit; docker-compose run `heroku config -a XXX-staging | tail +2 | tr -s " " | sed -E "s/^([^ ]+): (.+)/-e \1=\2/" | tr "\\n" " "` api rails c'
@parkan
parkan / ccr.md
Last active December 30, 2015 23:46 — forked from denisnazarov/ccr.md
Canonical Content Registry

Canonical Content Registry Foundation

Today, there is no reliable way to persist metadata for digital media as it travels across the internet.

Mine is working to build a global content registry on top of the Bitcoin blockchain to serve as an open metadata layer for canonical representations of digital media.

The goal of such a registry is to enable a new decentralized hypermedia protocol that powers the next generation of digital content applications, where creators and consumers to own their media, identity and interactions across the internet, without dependency on industrial or platform gatekeepers.

In March, we published a high level summary of how such such a system could work, titled the Canonical Content Registry. Today, we are taking the first steps to start building it by sharing a proposal for a technical implementation on top of Blockstore. We welcome your feedback and look forward to starting a conversation.

@parkan
parkan / ccr-resolver.md
Last active December 23, 2015 13:07
CCR Resolver

Design

This is the layer of the Canonical Content Registry that allows location of metadata identifiers pointing into the registration store based on perceptual similarity. The DHT is keyed by an appropriate perceptual hash (for example, Fixed Length MH Hash from phash.org for images) hashed again using a Locality Sensitive Hash such as RHH, which allows for efficient similarity search as in Hamming DHT. Keys that collide fully are chained and may be disambiguated as described below.

As in the Hamming DHT, near match keys may be returned, up to a threshold.

The values include a "name" identifier for the registration store and possibly several other perceptual hashes or other derived data (e.g. haar-like features, histogram, etc) for the work that can be used to further disambiguate the query. The client may send up these a

@parkan
parkan / mchain-resolve.sh
Last active January 25, 2016 18:05
Mediachain Resolver
# request fingerprint lookup from the API
% curl -X POST -H 'Content-Type: application/json' \
-d '{"image_url": "http://www.susanmeiselas.com/images/uploads/MolotovMan-Booklet_520p_70_1.jpg"}' \
https://mediachain-resolver.herokuapp.com/search
{
"matches": [
{
"confidence": 1.0,
"instance_id": "6580df51ed0d44b3a5519c1fc4e69e378df6ffde",
"metadata_id": "QmRBHQVmjKTv6ust1SVjJ4WLQb2p7PJaA1bEespBjb8SwY"
{
"10d13b93acbd9b62": "QmaDZCS2g1S6Z5yzPYqNDs9rycJyFzkehHocSVkuH5LpQv",
"114726d3c6d6558f": "QmRALYmxXnA7MZTXJGvrRg2XLKqEJxL6Vt55AdQG73sntB",
...
}
% ./perceptive-client.py 300px-Susan_Meiselas_-_Molotov_Man.jpg
Searching with input image 300px-Susan_Meiselas_-_Molotov_Man.jpg
perceptual hash: afe9d44ba135198a
Using IPFS daemon at 127.0.0.1:5001, id: QmRW2PTGpWk2X5sDbAvyDLV8668skcF8ADr1FcaP8VtC1q
Fetching metadata from /ipfs/QmRBHQVmjKTv6ust1SVjJ4WLQb2p7PJaA1bEespBjb8SwY
{
"@context": "http://schema.org",
"image_id": "c2ba20ae-8ccc-11e5-b627-83bff0768b7d",
"thumbnailUrl": {
"mlink": "QmXNDXmqfd9p5XXm6EBm6D2i1FbsaBQyBNEieZ2Czhxi77"
% git clone git@github.com:mediachain/L-SPACE.git && cd L-SPACE && sbt test
$ virtualenv venv
$ source venv/bin/activate
(venv) $ pip install -U pip
(venv) $ pip install mediachain-client
(venv) $ mediachain get Qmd2EEpQXnxd4HDpaDLymwRBUniS4tJvFXktNBW3kMd5ut
{
"metaSource": {
"@link": "Qmcbo67Ycv6rCREhQYoYeGJzgAJiCZDfyEdtHqdbmTsv6T"
},
"meta": {
(venv) $ mkdir artsy
(venv) $ curl https://artsy-random-image.herokuapp.com/ > artsy/001.json
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3164 100 3164 0 0 3323 0 --:--:-- --:--:-- --:--:-- 3323
(venv) $ mediachain ingest artsy@QmTvzPcDjKyAP9nx3tLnE3k9kMmB4QXF7hzZTM2vLDHtUA artsy
Inserted canonical: QmaQoM65kDsVR2SPfovGRdjirUaau8SKTfHVL4fgwP4PCM
(venv) $ mediachain get QmaQoM65kDsVR2SPfovGRdjirUaau8SKTfHVL4fgwP4PCM
{
"metaSource": {
$ curl indexer.mediachain.io:23456/search -d '{"q": "actor"}'
{
"cache_hit": true,
"next_page": {
"limit": 15,
"offset": 15,
"token": "e10fea03553d2c9058b156287e866add"
},
"prev_page": null,
"results": [