Skip to content

Instantly share code, notes, and snippets.

@lovesh
lovesh / github_stats.py
Created April 8, 2021 13:52
Python 3 script to get users interacting with github repos
import urllib.request, json
# Will get users interacting with these repos
repositories = [
'docknetwork/sdk',
'docknetwork/dock-substrate',
'docknetwork/rify',
'docknetwork/vc-api',
'docknetwork/vcdm-verifier',
'docknetwork/price-feed-adapter',
@lovesh
lovesh / dock-subscan.json
Last active March 22, 2021 17:24
Dock types for Subscan
{
"Address": "MultiAddress",
"LookupSource": "MultiAddress",
"Keys": "SessionKeys2",
"PerDispatchClassU32": {
"type": "struct",
"type_mapping": [
["normal", "u32"],
["operational", "u32"],
["mandatory", "u32"]
@lovesh
lovesh / TempContract.sol
Last active April 17, 2018 02:33
Temporary contract to check pairing operations
pragma solidity ^0.4.14;
pragma experimental ABIEncoderV2;
import './verifier.sol';
contract TempContract is Verifier {
bool public success = false;
event Trace0(string);
function verifyFifteen(
uint[2] a,
uint[2] a_p,
@lovesh
lovesh / Verifier.sol
Created April 13, 2018 22:21
Zokrates factorization contract
pragma solidity ^0.4.14;
library Pairing {
struct G1Point {
uint X;
uint Y;
}
// Encoding of field elements is: X[0] * z + X[1]
struct G2Point {
uint[2] X;
@lovesh
lovesh / factor_test.js
Created April 13, 2018 22:17
Test for Zokrates contract
var Web3 = require("../node_modules/web3/");
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
var Verifier = require("../contracts/Verifier.sol");
contract('Verifier', function (accounts) {
var verifier;
before(function () {
return Verifier.new({ from: web3.eth.accounts[0], value: 10000000000000000000, gas: 2100000 })
@lovesh
lovesh / rocks_int_comparator.py
Created July 17, 2017 22:35
# Add integer keys in rocksdb and get highest and lowest keys using a custom comparator
# Add integer keys in rocksdb and get highest and lowest keys using a custom comparator
import random
import string
from time import perf_counter
import rocksdb
from rocksdb.interfaces import Comparator
class IntegerComparator(Comparator):
@lovesh
lovesh / ujson_msgpack_benchmark.py
Created July 17, 2017 19:49
Comparison of serialisation and de-serialisation times on some plenum message
from random import shuffle
import ujson
import msgpack
import time
data = [
{"op":"REPLY","result":{"txnTime":1500296923,"rootHash":"ChEG5bpqvdKYhyoqSziJ5r7qtyRtkmjQYzErEW2DpuqC","type":"buy","auditPath":["3uAnG8h5rS5nwviEj49YTje8GA8tS19RsUP3MvSju9gG"],"signature":"5RGoVb8Rsc4H1jn2FZdueBAZ3kMzwJhEzLUjxtMhzXSBnQBuE438uj8Bg1b5eP82EYNKVNwFSarztQoDszid6n8w","reqId":1500316722698678,"identifier":"4AdS22kC7xzb4bcqg9JATuCfAMNcQYcZa1u5eWzs6cSJ","seqNo":33,"amount":10}},
{"op":"REPLY","result":{"txnTime":1500296923,"rootHash":"FMWErPC9tCMusWjwfgLkhKoibQbwWWoCYWjFj9TTmHuj","type":"buy","auditPath":["AbBrT7ScWCPdKkCue5SyWx8jCvUFwgDPBSumNtGmuLYG","7qB28FcEsR93j3CrmYpAG5r1JJZAVrNHWtMKcYHspgkY","7CGsMw6jBaq8Cm5dfb1BmoV1LHk4kVjRYV83r4B1xMw9"],"signature":"3xuFE9kEo8L991Z4ztLuwgyeUTTbTW6dauKLcMbbeFffK1hRj6ywTGz3m5nhzEk5LqQQsfXTd7rq6hHchnpUSxzg","reqId":1500316722693789,"identifier":"4AdS22kC7xzb4bcqg9JATuCfAMNcQYcZa1u5eWzs6cSJ","seqNo":29,"amount":28}},
{"op":"REPLY","result":{"txnTime":1500296923,"rootHash":"Dj2VKTBE
Verifying that +lovesh is my blockchain ID. https://onename.com/lovesh
@lovesh
lovesh / email_generator.py
Created October 8, 2014 03:59
Email generator according to the spreadsheet http://bit.ly/name2email
import itertools
name = 'FirstName MiddleName LastName'
company_domain = 'company.com'
name_parts = name.lower().split(' ')
fname, mname, lname = None, None, None
if len(name_parts) > 0:
fname = name_parts[0]
@lovesh
lovesh / dom.py
Last active August 29, 2015 14:06
playing with HTML DOM using lxml
import lxml.html
import urllib2
class DOM(object):
def __init__(self, url=None, html=None, utf8=False):
if url:
page = urllib2.urlopen(url)
html = page.read()
page.close()