Skip to content

Instantly share code, notes, and snippets.

View itzmeanjan's full-sized avatar
😎
Working ...

Anjan Roy itzmeanjan

😎
Working ...
View GitHub Profile
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) {
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 October 26, 2019 03:35
A simple Python script, designed to extract all public project details ( as JSON ), from a GitHub User Profile, by scraping out webpages. Made with ❤️
#!/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 March 29, 2020 07:27
JioFi 3 router's battery status extractor & notifier ( using Linux desktop notification )
#!/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 September 6, 2020 09:12
ChainLink's LINK Token upgrade for mapping on Matic Network [ also deployment details ]
*.sol linguist-language=Solidity
@itzmeanjan
itzmeanjan / ChildERC20.sol
Last active July 6, 2021 06:43
An illustration of sending data from Ethereum root chain to Matic child chain
// File: contracts/child/ChildToken/ChildERC20.sol
pragma solidity 0.6.6;
contract ChildERC20 is
ERC20,
IChildToken,
AccessControlMixin,
NativeMetaTransaction,
ChainConstants,
@itzmeanjan
itzmeanjan / Decoder.sol
Created February 2, 2021 04:54
Smart contract for decoding State Sync data from Ethereum to Matic
// 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 February 8, 2021 12:25
Smart contract for decoding Matic Network's check point signer addresses
// 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 March 2, 2021 09:16
Smart contract for decoding checkpoint submission data from Matic Network ( L2 ) to Ethereum Network ( L1 )
// 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 06:08
Submit bulk Tx @ Matic DA Blockchain
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