Skip to content

Instantly share code, notes, and snippets.

View niksmac's full-sized avatar
🇮🇳
🧜 Merperson

Nikhil M niksmac

🇮🇳
🧜 Merperson
View GitHub Profile
{
"nonce": "0x0000000000000042",
"difficulty": "0x400000000",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x322ba94575eae5dc36efa11d35923c53e75a425e",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
"gasLimit": "0x1388",
"alloc": {}
/**
* Ethereum Account Scanner
*
* To run this, you need your own geth node, accepting RPC
* connections on a port you can access.
*
* Install pre-requisites:
* sudo npm install -g web3
*
* Usage:
@niksmac
niksmac / zmv-examples.md
Created March 7, 2017 05:58
ZMV-Examples (require autoload zmv)

rename a section of a filename, i. e. example.1.{txt,conf,db} or 12345.1.{wav,ogg,mp3} and

change the 1 to a 2 in the filename while preserving the rest of it.

$ zmv -n '(.)(<->)(.[^.]#)' '$1$(($2+1))$3' # would rename x.0001.y to x.2.y. $ zmv -n '(.0#)(<->)(.[^.]#)' '$1$(($2+1))$3'

Rename files to lower case

$ zmv '*' '${(L)f}'

serially all files (foo.foo > 1.foo, fnord.foo > 2.foo, ..)

$ autoload zmv

@niksmac
niksmac / fix_npm.sh
Last active January 9, 2023 22:36
Fixing npm permissions
#!/usr/bin/env bash
set -e
echo ''
info () {
printf "\r [ \033[00;34m..\033[0m ] $1\n"
}
/**
* Base contract that all upgradeable contracts should use.
*
* Contracts implementing this interface are all called using delegatecall from
* a dispatcher. As a result, the _sizes and _dest variables are shared with the
* dispatcher contract, which allows the called contract to update these at will.
*
* _sizes is a map of function signatures to return value sizes. Due to EVM
* limitations, these need to be populated by the target contract, so the
* dispatcher knows how many bytes of data to return from called functions.
@niksmac
niksmac / pointless-blockchain-project.md
Last active August 21, 2018 13:31
Avoiding the pointless blockchain project

How to determine if you’ve found a real blockchain use case

Blockchains are overhyped. There, I said it. From Sibos to Money20/20 to cover stories of The Economist and Euromoney, everyone seems to be climbing aboard the blockchain wagon. And no doubt like others in the space, we’re seeing a rapidly increasing number of companies building proofs of concept on our platform and/or asking for our help.

As a young startup, you’d think we’d be over the moon. Surely now is the time to raise a ton of money and build that high performance next generation blockchain platform we’ve already designed. What on earth are we waiting for? censorship

I’ll tell you what. We’re waiting to gain a clearer understanding of where blockchains genuinely add value in enterprise IT. You see, a large proportion of these incoming projects have nothing to do with blockchains at all. Here’s how it plays out. Big company hears that blockchains are the next big thing. Big company finds some people internally who are interested in the su

  1. Describe why it’s hard to code a random number generator in Ethereum. Summarize a few reasons why most intuitive solutions fail (eg. getting from block number)

  2. Describe an efficient approach to using off-chain data in an ethereum contract that minimizes the amount of trust required.

  3. Create an efficient solidity contract that includes the following functions:

  • sqrt(uint x) that returns the square root of a number to 2 decimal places
  • selectionsort(uint[] x) that uses the selection sort algorithm to return a sorted array
  • factorial(int x): returns the factorial of x using recursion
@niksmac
niksmac / Ethereum_testnet.md
Created September 3, 2016 13:10 — forked from 0mkara/Ethereum_private_network.md
Ethereum testnet configuration guide.

Create your own Ethereum testnet

Introduction

We will be using 3 virtual machines as 3 Ethereum node. We used 'Ubuntu Server 14.04 LTS trusty', and 'Ubuntu 15.10 wily' for this experiment. Root Ethereum node will be referred as 'root node', client nodes will be referred as 'client node A' & 'client node B' respectively. On root node port 30303 must be accessible from outside.

Installation

Below are the installation instructions for the latest versions of Ubuntu. This step must be executed and Ethereum go client 'geth' must be installed on every node.

@niksmac
niksmac / duplicatedb.sh
Last active August 25, 2016 04:02
MySQL script to copy/duplicate database from linux terminal.
#!/bin/bash
DBUSER=user
DBPASSWORD=pwd
DBSNAME=sourceDb
DBNAME=destinationDb
DBSERVER=localhost
fCreateTable=""
fInsertData=""

Keybase proof

I hereby claim:

  • I am niksmac on github.
  • I am niksmac (https://keybase.io/niksmac) on keybase.
  • I have a public key ASDIN9pUfXhvZO_R2C2Co5XPM8HjOBrfznFX0WD80TDEVwo

To claim this, I am signing this object: