Skip to content

Instantly share code, notes, and snippets.

View kvhnuke's full-sized avatar
🤗
1100011

Kosala Hemachandra kvhnuke

🤗
1100011
View GitHub Profile
0x80aC8D1496b9c0F2cFdBe2a9AD827707AF7D3F52
@kvhnuke
kvhnuke / swap.js
Created April 23, 2018 21:24
swap
let doAssignment = true;
$scope.kyberSwapRateDisplay();
let bityOptions = ["ETH", "BTC", "REP"];
let kyberOptions = $scope.availableTokens;
let isBity = (_coin) => {
return bityOptions.indexOf(_coin) > -1;
}
if (isFrom) {
$scope.availableToOptions = []
if (isBity(coin)) {
@kvhnuke
kvhnuke / docker-upgrade.sh
Created July 4, 2018 03:26
Upgrade docker images
sudo docker stop $(sudo docker ps -a -q)
sudo docker rm $(sudo docker ps -a -q)
sudo bash /var/lib/cloud/instances/i-*/user-data.txt
#ssh -i [pem file location].pem ubuntu@[ip-address] 'bash -s' < ~/upgrade-docker.sh
@kvhnuke
kvhnuke / web3.js
Created August 6, 2018 18:54
web3 overide
const Web3 = require('web3')
const Web3Method = require('web3-core-method')
let web3 = new Web3('https://api.myetherwallet.com/eth')
let reqM = {
send(tx, cb) {
console.log(tx)
}
}
// web3.eth.extend({
// methods: [{
@kvhnuke
kvhnuke / ipfs-publish.sh
Last active September 26, 2018 05:39
publish ipfs
GNU nano 2.5.3 File: ipfs-publish.sh
#!/bin/bash
source ~/.profile
if [ "$#" -ne 1 ]; then
echo "usage:"
echo " ipfs-publish.sh <dir>"
echo " ipfs-publish.sh -- (read .tar.bzip2 archive from stdin)"
echo " example: tar -cjvf - dist | ./ipfs-publish.sh --"
exit 1
@kvhnuke
kvhnuke / mew-export-{{date-time}}.json
Last active December 12, 2018 02:56
MEWv5 JSON export/import format
{
"timestamp": "2018-12-12T02:39:51.982Z",
"main":{
"customTokens": [{
"name":"MyEtherWallet",
"symbol":"MEW",
"decimals": 18
}],
"customNetworks":[{
"name": "MyEtherWallet API",
@kvhnuke
kvhnuke / openssl.sh
Created January 24, 2019 03:45
OpenSSL ssl cert commands
# get sha-256 fingerprint of ssl cert
openssl s_client -showcerts -connect myetherwallet.com:443 </dev/null 2>/dev/null | openssl x509 -noout -fingerprint -sha256 -inform pem
# export ssl cert of a website to pem
openssl s_client -showcerts -connect beta.myetherwallet.com:443 </dev/null 2>/dev/null|openssl x509 -outform PEM > mycertfile.pem
@kvhnuke
kvhnuke / survey-giveaway.md
Last active February 1, 2019 06:15
Survey giveaway guide

MyEtherWallet v5 Survey

5 MEW Engraved Ledger Nano S Giveaway

Rules

  • Survey must be thoughtful
  • Valid
  • No spamming
  • Must answer all questions, including open ended responses
@kvhnuke
kvhnuke / genesis-generator.js
Last active January 31, 2019 06:41
Generate genesis block with n number of prefilled accounts
import bip39 from "bip39";
import hdWallet from "ethereumjs-wallet/hdkey";
import cluster from "cluster";
import fs from "fs";
const ETH_PATH = "m/44'/60'/0'/0";
const NUM_CPUS = 8;
const NUM_ACCOUNTS_PER_CORE = 200000;
const mnemonic =
"source pitch chronic mother need ghost unable asset supreme tragic else interest asset eagle update rule slim elder adapt next emerge trash doctor fun";
const seed = bip39.mnemonicToSeed(mnemonic);
@kvhnuke
kvhnuke / 200mil-eth-genesis.js
Created January 31, 2019 02:20
Generate 200 million eth account genesis
const fs = require("fs");
var JSONStream = require("JSONStream");
var LIMIT = 200000000;
var transformStream = JSONStream.stringifyObject(
'{"config":{"chainId":15,"homesteadBlock":0,"eip155Block":0,"eip158Block":0},"difficulty":"20","gasLimit":"2100000","alloc":{',
",",
"}}"
);
var outputStream = fs.createWriteStream("./sample-genesis.json");
transformStream.pipe(outputStream);