Skip to content

Instantly share code, notes, and snippets.

View gauthamzz's full-sized avatar
🐻‍❄️
Building

Gautham Santhosh gauthamzz

🐻‍❄️
Building
View GitHub Profile
@gauthamzz
gauthamzz / dfa.py
Created January 10, 2017 11:01
Python DFA code to recognize the reserved keywords.
class Automaton:
def __init__(self, nstates):
self.transitions = [{} for i in range(nstates)]
self.accept_states = [False] * nstates
def register(self, source_state, char, target_state):
self.transitions[source_state][char] = target_state
def register_accept(self, state):
self.accept_states[state] = True
@gauthamzz
gauthamzz / fetch_pull_request
Created February 23, 2018 11:58
script to fetch pull request in a new branch.
#!/bin/bash
if [ "$1" == "--help" ]; then
printf "Usage: fetch-pull-request [--help] pull_request_id [remote=upstream] \n\n Locally fetch a pull request and test it. \n Remote is set to upstream by default.\n"
exit 1
elif [ $# -eq 0 ]; then
echo "Pull request id not given."
exit 1
else
set -e -x
remote=${2:-upstream}
Verifying my Blockstack ID is secured with the address 1AsKEABwZNuuY8PuYQaGPfvv9nLEr4gkSA https://explorer.blockstack.org/address/1AsKEABwZNuuY8PuYQaGPfvv9nLEr4gkSA
{
"name": "mast rcnn balloon",
"version": "2.1",
"url": "https://github.com/matterport/Mask_RCNN/releases/download/v2.1/mask_rcnn_balloon.h5",
"description": "We train the model to detect balloons only, and then we use the generated masks to keep balloons in color while changing the rest of the image to grayscale.",
"input_parameters": "<optional>",
"output_parameters": "<optional",
"repository": {
"type": "git",
"sample": "https://github.com/matterport/Mask_RCNN/tree/master/samples/balloon",
@gauthamzz
gauthamzz / abci-console.sh
Last active January 31, 2019 21:24
Tendermint KV store
# Lets do in a different way
tendermint init --home ".node"
# Start a tendermint node
tendermint node --home ".node"
# Open a new terminal and start kvstore from abci-console
abci-console kvstore
# Open new terminal and start abci-console
# Create the genesis block, for the node.
tendermint init
# Now that the gensis block is inilaised we can start
# the application on the system
tendermint node --proxy_app=kvstore
# This will start the kvstore application in your
# computer in port 26657.
# Lets test the kv store application by sending a request to the application
class State(object):
def __init__(self, db, size, height, apphash):
self.db = db
self.size = size
self.height = height
self.apphash = apphash
def deliver_tx(self, tx):
"""Validate the transaction before mutating the state.
Args:
raw_tx: a raw string (in bytes) transaction.
"""
parts = tx.split(b'=')
if len(parts) == 2:
key, value = parts[0], parts[1]
else:
key, value = tx
def commit(self):
byte_length = max(ceil(self.state.size.bit_length() / 8), 1)
app_hash = self.state.size.to_bytes(byte_length, byteorder='big')
self.state.app_hash = app_hash
self.state.height += 1
self.state.save()
return ResponseCommit(data=app_hash)
def query(self, req):
value = self.state.db.get(prefix_key(req.data))
return ResponseQuery(code=CodeTypeOk, value=value)