Skip to content

Instantly share code, notes, and snippets.

View subhodi's full-sized avatar
🎯
Focusing

Subhod I subhodi

🎯
Focusing
  • Goa
View GitHub Profile
@subhodi
subhodi / geth-util.js
Last active February 7, 2018 05:50
Useful scripts for Go-Ethereum command line
// Block with maximum transaction
var max=0;
for (var i = 0; i < eth.blockNumber; i++) {
if (web3.eth.getBlock(max).transactions.length < web3.eth.getBlock(i).transactions.length) {
console.log(i, web3.eth.getBlock(i).transactions.length);
max = i;
}
}
// auto-mining
@subhodi
subhodi / keybindings.json
Last active March 28, 2018 10:18
NODEJS console.log key bindings for vscode
// Place your key bindings in this file to overwrite the defaults
// 1. Ctrl+q to insert console.log()
// 2. Ctrl+shift+q to insert console.log("")
// 3. Ctrl+shift+y to insert console.log with yellow text config
// 4. ctlr=shift+i to insert License using fileHeader externsion
[
{
"key": "ctrl+q",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
@subhodi
subhodi / QuickSort.sol
Created December 14, 2017 08:31
Quick sort in Solidity for Ethereum network
pragma solidity ^0.4.18;
contract QuickSort {
function sort(uint[] data) public constant returns(uint[]) {
quickSort(data, int(0), int(data.length - 1));
return data;
}
function quickSort(uint[] memory arr, int left, int right) internal{
@subhodi
subhodi / arrayBufferToBase64.js
Last active December 21, 2021 18:48
arrayBufferToBase64 and vice versa
function arrayBufferToBase64(buffer) {
var binary = '';
var bytes = new Uint8Array(buffer);
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
}
@subhodi
subhodi / erc-20.sol
Created September 19, 2017 10:30
ERC20 token
pragma solidity ^0.4.8;
// ----------------------------------------------------------------------------------------------
// Sample fixed supply token contract
// Enjoy. (c) BokkyPooBah 2017. The MIT Licence.
// ----------------------------------------------------------------------------------------------
// ERC Token Standard #20 Interface
// https://github.com/ethereum/EIPs/issues/20
contract ERC20Interface {
// Create a key pair
web3.shh.newKeyPair();
.then(console.log);
> "5e57b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f"
// Check key pair exist
web3.shh.hasKeyPair('fe22b9ffc2387e18636e0a3d0c56b023264c16e78a2adcba1303cefc685e610f');
.then(console.log);
> true
info: [EventHub.js]: _connect - options {"grpc.ssl_target_name_override":"peer0.or g1.example.com","grpc.default_authority":"peer0.org1.example.com"}
[2017-07-21 09:59:27.966] [DEBUG] Helper - [crypto_ecdsa_aes]: ecdsa signature: S ignature {
r: <BN: e1cdeef11d37de28810bed04d525abf4ed4959899f64e7129483110b07d9ef50>,
s: <BN: 65720ba0dfcdb959cce0a3d69b016097c7895aab1891172ded659aece90d467e>,
recoveryParam: 1 }
PuTTY[2017-07-21 09:59:27.978] [DEBUG] Helper - [crypto_ecdsa_aes]: ecdsa signatur e: Signature {
r: <BN: 47028e47741d48d47049b71306f62a9ffe4859db5199ef48ff57c09010168e37>,
s: <BN: 3324b0b2f34fda7681ca68860b3498bc7c91b164c54c500dce66e316f9b345bc>,
recoveryParam: 1 }
E0721 09:59:27.993354043 21148 ssl_transport_se
2017-07-21 04:28:58.581 UTC [orderer/main] Deliver -> DEBU 26a Starting new Deliver handler
2017-07-21 04:28:58.581 UTC [orderer/common/deliver] Handle -> DEBU 26b Starting new deliver loop
2017-07-21 04:28:58.581 UTC [orderer/common/deliver] Handle -> DEBU 26c Attempting to read seek info mes sage
2017-07-21 04:28:58.582 UTC [policies] GetPolicy -> DEBU 26d Returning policy Readers for evaluation
2017-07-21 04:28:58.582 UTC [cauthdsl] func1 -> DEBU 26e 0xc420026050 gate 1500611338582209665 evaluatio n starts
2017-07-21 04:28:58.582 UTC [cauthdsl] func2 -> DEBU 26f 0xc420026050 signed by 0 principal evaluation s tarts (used [false])
2017-07-21 04:28:58.582 UTC [cauthdsl] func2 -> DEBU 270 0xc420026050 processing identit
2017-07-21 04:28:24.425 UTC [endorser] ProcessProposal -> DEBU ee8 Entry
2017-07-21 04:28:24.425 UTC [protoutils] ValidateProposalMessage -> DEBU ee9 ValidateProposalMessage sta rts for signed proposal 0xc421720390
2017-07-21 04:28:24.425 UTC [protoutils] validateChannelHeader -> DEBU eea validateChannelHeader info: h eader type 3
2017-07-21 04:28:24.425 UTC [protoutils] checkSignatureFromCreator -> DEBU eeb checkSignatureFromCreator starts
2017-07-21 04:28:24.426 UTC [protoutils] checkSignatureFromCreator -> DEBU eec checkSignatureFromCreator info: creator is &{Org1MSP ed2817b918dbc4f74484cbd8e71e3be1b36c2d22adb217bc2e37