Skip to content

Instantly share code, notes, and snippets.

View upperwal's full-sized avatar

Abhishek Upperwal upperwal

View GitHub Profile
0xe1Bd4F281DD51f6970b14064df2790F3559C5069
package main

import (
	"bufio"
	"context"
	"fmt"
	"time"
	"os"
@upperwal
upperwal / a_tree_based_bcast.go
Last active May 2, 2023 08:50
Binary tree based Broadcast
package main
/* Binary tree based Broadcast
* This program demonstrates a tree based broadcast to all the peers in a network.
* Program starts by arranging a set of peers in a tree structure were a node is
* connected to exactly two nodes, it's children. This gives an almost complete binary tree.
*
* One-way flow of information:
* Data can only flow from top to bottom in the graph. So, if the root node initiates
* a broadcast. It will send the message to it's children who will then send it to their
package main
import (
"bufio"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/tls"
"crypto/x509"
"errors"
package main
import (
"context"
"fmt"
mrand "math/rand"
logging "github.com/ipfs/go-log"
libp2p "github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p-crypto"
@upperwal
upperwal / pravah_air_quality_subscriber.py
Last active November 15, 2019 16:36
Air Quality data on Pravah
# pip3 install mesh-air-quality
from mesh_air_quality.main import MeshAirQuality
geospace = [
'/in/ncr'
]
def main():
c = MeshAirQuality('rpc.pravah.io:5555')
{
"header": {
"version": "0.0.1",
"timestamp": 154635342
},
"stations": [
{
"id": "station_1",
"powerGenerationParameters": {
-       1            2            3           4               5                 6                 7                   8               9           10          11             
-  -----------  -----------  -----------  -----------  ---------------  ----------------  ------------------  ----------------  ---------  ----------  -----------
0  Chennai      Guwahati     Pune         New Delhi    Visakhapatnam    Bhopal            Ahmedabad           Indore            Ludhiana   Coimbatore  Belagaavi
1  Lucknow      Warangal     Dharamasala  Agartala     Raipur           New Town Kolkata  Ranchi              Panaji            Imphal     Chandigarh  Port Blair
2  Kanpur       Ajmer        Salem        Aurangabad   Rourkela         Kota              Hubli-Dharwad       Kalyan            Thanjavur  Tumakuru    Vellore
3  Tirunelveli  Naya Raipur  Prayagraj    Bangalore    Thoothukudi      Puducherry        Shimla              Pimpri Chinchwad  Karnal     Satna       Gandhinagar
4  Shillong     Kavaratti    Silvassa 
{
"IN-AN": "Andaman And Nicobar Islands",
"IN-AP": "Andhra Pradesh",
"IN-BR": "Bihar",
"IN-CH": "Chandigarh",
"IN-CT": "Chhattisgarh",
"IN-DL": "Delhi",
"IN-GA": "Goa",
"IN-GJ": "Gujarat",
"IN-HR": "Haryana",
{
"round1": [
"Bhubaneswar",
"Pune",
"Jaipur",
"Surat",
"Kochi",
"Ahmedabad",
"Jabalpur",
"Visakhapatnam",