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 / go-ipld-p2-0.go
Created January 22, 2020 22:06
SimpleAsWater Tutorial: Hands On IPLD Tutorial: PART 2
// SampleStruct defines the benchmark payload
type SampleStruct struct {
ID string `json:"ID"`
Name string `json:"Name"`
Salary string `json:"Salary"`
}
@vasa-develop
vasa-develop / go-snippet-5.go
Created January 4, 2020 19:11
SimpleAsWater: Hands-on IPLD Tutorial in Golang
// Fetch the details by reading the DAG for key "inputKey"
fmt.Printf("READ: Value for key \"%s\" is: ", inputKey)
res, err := GetDag(cid, inputKey)
if err != nil {
fmt.Println(err)
}
fmt.Println(res)
@vasa-develop
vasa-develop / go-snippet-4.go
Created January 4, 2020 19:10
SimpleAsWater: Hands-on IPLD Tutorial in Golang
// Dag PUT operation which will return the CID for futher access or pinning etc.
cid, err := sh.DagPut(entryJSON, "json", "cbor")
if err != nil {
fmt.Fprintf(os.Stderr, "error: %s", err)
os.Exit(1)
}
fmt.Println("------\nOUTPUT\n------")
fmt.Printf("WRITE: Successfully added %sHere's the IPLD Explorer link: https://explore.ipld.io/#/explore/%s \n", string(cid+"\n"), string(cid+"\n"))
@vasa-develop
vasa-develop / go-snippet-3.go
Created January 4, 2020 19:09
SimpleAsWater: Hands-on IPLD Tutorial in Golang
// Converting into JSON object
entryJSON, err := json.Marshal(m)
if err != nil {
fmt.Println(err)
}
// Display the marshaled JSON object before sending it to IPFS
jsonStr := string(entryJSON)
fmt.Println("The JSON object of your key-value entry is:")
fmt.Println(jsonStr)
@vasa-develop
vasa-develop / go-snippet-2.go
Created January 4, 2020 19:08
SimpleAsWater: Hands-on IPLD Tutorial in Golang
scanner := bufio.NewScanner(os.Stdin)
fmt.Println("Enter value for the key field: ")
scanner.Scan()
inputKey := scanner.Text()
fmt.Println("Enter value for value field: ")
scanner.Scan()
inputValue := scanner.Text()
// Setting the key and values in the mapping
m[inputKey] = inputValue
@vasa-develop
vasa-develop / go-snippet-1.go
Created January 4, 2020 19:07
SimpleAsWater: Hands-on IPLD Tutorial in Golang
// Mapping-based structure to record key-value information
keyValueMap := make(map[string]interface{})
@vasa-develop
vasa-develop / full-earth.js
Created December 28, 2019 12:39
SimpleAsWater: Building a Chat Application using Libp2p
'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')
@vasa-develop
vasa-develop / full-moon.js
Created December 28, 2019 12:39
SimpleAsWater: Building a Chat Application using Libp2p
'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 Pushable = require('pull-pushable')
const p = Pushable()
const chalk = require('chalk');
@vasa-develop
vasa-develop / moon_03.js
Created December 28, 2019 12:36
SimpleAsWater: Building a Chat Application using Libp2p
'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 Pushable = require('pull-pushable')
const p = Pushable()
const chalk = require('chalk');
const emoji = require('node-emoji')
@vasa-develop
vasa-develop / earthId.json
Created December 28, 2019 12:35
SimpleAsWater: Building a Chat Application using Libp2p
{
"id": "Qma3GsJmB47xYuyahPZPSadh1avvxfyYQwk8R3UnFrQ6aP",
"privKey": "CAASpwkwggSjAgEAAoIBAQCaNSDOjPz6T8HZsf7LDpxiQRiN2OjeyIHUS05p8QWOr3EFUCFsC31R4moihE5HN+FxNalUyyFZU//yjf1pdnlMJqrVByJSMa+y2y4x2FucpoCAO97Tx+iWzwlZ2UXEUXM1Y81mhPbeWXy+wP2xElTgIER0Tsn/thoA0SD2u9wJuVvM7dB7cBcHYmqV6JH+KWCedRTum6O1BssqP/4Lbm2+rkrbZ4+oVRoU2DRLoFhKqwqLtylrbuj4XOI3XykMXV5+uQXz1JzubNOB9lsc6K+eRC+w8hhhDuFMgzkZ4qomCnx3uhO67KaICd8yqqBa6PJ/+fBM5Xk4hjyR40bwcf41AgMBAAECggEAZnrCJ6IYiLyyRdr9SbKXCNDb4YByGYPEi/HT1aHgIJfFE1PSMjxcdytxfyjP4JJpVtPjiT9JFVU2ddoYu5qJN6tGwjVwgJEWg1UXmPaAw1T/drjS94kVsAs82qICtFmwp52Apg3dBZ0Qwq/8qE1XbG7lLyohIbfCBiL0tiPYMfkcsN9gnFT/kFCX0LVs2pa9fHCRMY9rqCc4/rWJa1w8sMuQ23y4lDaxKF9OZVvOHFQkbBDrkquWHE4r55fchCz/rJklkPJUNENuncBRu0/2X+p4IKFD1DnttXNwb8j4LPiSlLro1T0hiUr5gO2QmdYwXFF63Q3mjQy0+5I4eNbjjQKBgQDZvZy3gUKS/nQNkYfq9za80uLbIj/cWbO+ZZjXCsj0fNIcQFJcKMBoA7DjJvu2S/lf86/41YHkPdmrLAEQAkJ+5BBNOycjYK9minTEjIMMmZDTXXugZ62wnU6F46uLkgEChTqEP57Y6xwwV+JaEDFEsW5N1eE9lEVX9nGIr4phMwKBgQC1TazLuEt1WBx/iUT83ita7obXqoKNzwsS/MWfY2innzYZKD