Skip to content

Instantly share code, notes, and snippets.

View vasa-develop's full-sized avatar
💭

vasa vasa-develop

💭
View GitHub Profile
@vasa-develop
vasa-develop / publication.js
Last active October 6, 2019 07:59
SimpleAsWater Tutorial - Building Online Publication using IPLD
/*
PUBLICATION SYSTEM
Adding new Author
An author will have
-> name
-> profile
Creating A Blog
A Blog will have a:
@vasa-develop
vasa-develop / nested_data.js
Created October 5, 2019 22:20
SimpleAsWater Tutorial - Building Online Publication using IPLD
//Initiate ipfs and CID instance
const ipfsClient = require('ipfs-http-client');
const CID = require('cids');
//Connecting ipfs http client instance to local IPFS peer.
const ipfs = new ipfsClient({ host: 'localhost', port: '5001', protocol: 'http' });
function errOrLog(err, result) {
if (err) {
console.error('error: ' + err)
@vasa-develop
vasa-develop / named_link.js
Created October 5, 2019 22:20
SimpleAsWater Tutorial - Building Online Publication using IPLD
@vasa-develop
vasa-develop / ipld_node.js
Created October 5, 2019 22:08
SimpleAsWater Tutorial - Building Online Publication using IPLD
//Initiate ipfs and CID instance
const ipfsClient = require('ipfs-http-client');
const CID = require('cids');
//Connecting ipfs http client instance to local IPFS peer.
const ipfs = new ipfsClient({ host: 'localhost', port: '5001', protocol: 'http' });
/*
Creating an IPLD format node:
ipfs.dag.put(dagNode, [options], [callback])
@vasa-develop
vasa-develop / ipld_links.json
Created October 5, 2019 20:38
SimpleAsWater Tutorial - Building Online Publication using IPLD
@vasa-develop
vasa-develop / gateway.js
Created October 5, 2019 10:00
SimpleAsWater Tutorial - Youtube on IPFS
//TODO: Retrieve the Data from the IPFS peer using IPFS Gateway
videoSrc.src = `http://localhost:8080/ipfs/${videos[i].hash}`
@vasa-develop
vasa-develop / app.js
Created October 5, 2019 07:39
SimpleAsWater Tutorial - Youtube on IPFS
//Initialize IPFS
const ipfs = window.IpfsHttpClient('localhost', '5001')
//Checking for File Upload
jQuery("input#customFile").change(function (event) {
const files = event.target.files;
//Converting the FileBlob to ArrayBuffer
@vasa-develop
vasa-develop / index.html
Created October 5, 2019 07:38
SimpleAsWater Tutorial - Youtube on IPFS
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Youtube on IPFS - SimpleAsWater</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://unpkg.com/ipfs-http-client/dist/index.min.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
@vasa-develop
vasa-develop / pdf-image-fix.txt
Created October 3, 2019 14:33
How to do html => pdf => img
html => pdf
use `html-pdf` module
pdf => img
use `pdf-image`
First install
sudo apt-get install imagemagick ghostscript poppler-utils
Then add permission for PDF using this:
@vasa-develop
vasa-develop / earth.js
Last active October 1, 2019 23:31
SimpleAsWater: Getting Started with Libp2p - NodeJS
'use strict'
/* eslint-disable no-console */
const PeerId = require('peer-id')
const PeerInfo = require('peer-info')
const Node = require('./libp2p_bundle')
const pull = require('pull-stream')
const async = require('async')
const chalk = require('chalk');
const emoji = require('node-emoji')