Skip to content

Instantly share code, notes, and snippets.

Avatar
😎
Working ...

Anjan Roy itzmeanjan

😎
Working ...
View GitHub Profile
View service_advertiser.dart
import 'dart:io'
show RawDatagramSocket, RawSocketEvent, InternetAddress, Datagram;
import 'dart:convert' show utf8;
main() =>
// UDP server
RawDatagramSocket.bind(InternetAddress.anyIPv4, 8000)
.then((datagramSocket) {
datagramSocket.readEventsEnabled = true;
datagramSocket.listen((RawSocketEvent event) {
View service_discoverer.dart
import 'dart:io'
show RawDatagramSocket, RawSocketEvent, InternetAddress, Datagram;
import 'dart:convert' show utf8;
main() =>
// UDP client
RawDatagramSocket.bind(InternetAddress.anyIPv4, 0).then((datagramSocket) {
datagramSocket.broadcastEnabled = true;
datagramSocket.readEventsEnabled = true;
datagramSocket.listen((RawSocketEvent event) {
@itzmeanjan
itzmeanjan / git_project_extractor.py
Last active Oct 26, 2019
A simple Python script, designed to extract all public project details ( as JSON ), from a GitHub User Profile, by scraping out webpages. Made with ❤️
View git_project_extractor.py
#!/usr/bin/python3
from requests import get
from sys import argv
from json import dump
from os.path import dirname, abspath, join
from urllib.parse import urljoin
from dateutil.parser import parse
from itertools import chain
from functools import reduce
@itzmeanjan
itzmeanjan / jiofiBatteryStat.py
Last active Mar 29, 2020
JioFi 3 router's battery status extractor & notifier ( using Linux desktop notification )
View jiofiBatteryStat.py
#!/usr/bin/python3
'''
Strictly use python version >=3.7.0, because script uses type hinting
Note that : This script doesn't work on Windows/ Mac i.e. notification
service will work only on Linux, having dependeny on `notify-send` program;
though extraction of battery status ( from router management portal )
can be done by this script on any platfrom, given that machine is
connected to JioFi router ( tested to be working on JioFi 3 )
@itzmeanjan
itzmeanjan / .gitattributes
Created Sep 6, 2020
ChainLink's LINK Token upgrade for mapping on Matic Network [ also deployment details ]
View .gitattributes
*.sol linguist-language=Solidity
@itzmeanjan
itzmeanjan / ChildERC20.sol
Last active Jul 6, 2021
An illustration of sending data from Ethereum root chain to Matic child chain
View ChildERC20.sol
// File: contracts/child/ChildToken/ChildERC20.sol
pragma solidity 0.6.6;
contract ChildERC20 is
ERC20,
IChildToken,
AccessControlMixin,
NativeMetaTransaction,
ChainConstants,
@itzmeanjan
itzmeanjan / Decoder.sol
Created Feb 2, 2021
Smart contract for decoding State Sync data from Ethereum to Matic
View Decoder.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
contract Decoder {
bytes32 public constant DEPOSIT = keccak256("DEPOSIT");
bytes32 public constant MAP_TOKEN = keccak256("MAP_TOKEN");
enum SyncType {Deposit, TokenMapping, Unsupported}
@itzmeanjan
itzmeanjan / DecodeCheckpointSignerList.sol
Last active Feb 8, 2021
Smart contract for decoding Matic Network's check point signer addresses
View DecodeCheckpointSignerList.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract DecodeCheckpointSignerList {
// Slice specified number of bytes from arbitrary length byte array, starting from certain index
function slice(bytes memory payload, uint256 start, uint256 length) internal pure returns (bytes memory) {
require(length + 31 >= length, "slice_overflow");
@itzmeanjan
itzmeanjan / DecodeCheckpointSignerListV2.sol
Last active Mar 2, 2021
Smart contract for decoding checkpoint submission data from Matic Network ( L2 ) to Ethereum Network ( L1 )
View DecodeCheckpointSignerListV2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// Here's v1 of this contract : https://gist.github.com/itzmeanjan/5b7c6e973bc0785018cce100ee68fee7
//
// 👆 used for decoding checkpoint submission data previously, after recent change in the way
// checkpoints are to be submitted to Ethereum, 👇 is supposed to be used
//
// Call `decode` pure function with `txInput` of `submitHeaderBlock(bytes data, uint256[3][] sigs)` tx
@itzmeanjan
itzmeanjan / index.js
Last active May 11, 2021
Submit bulk Tx @ Matic DA Blockchain
View index.js
const { ApiPromise, WsProvider, Keyring } = require('@polkadot/api')
const { Buffer } = require('buffer')
const { createWriteStream } = require('fs')
const BATCH = process.env.BATCH || 100 // these many tx(s) to be attempted to be submitted
const PAYLOAD = process.env.PAYLOAD || 512 // in terms of bytes
const WSURL = process.env.WSURL || 'ws://localhost:9944'
// To be initialized, after `setUp` is called
let handle