Skip to content

Instantly share code, notes, and snippets.

View SauravKanchan's full-sized avatar
🏠
Working from home

Saurav Kanchan SauravKanchan

🏠
Working from home
View GitHub Profile
@SauravKanchan
SauravKanchan / piano.py
Last active September 18, 2017 18:06
Playing piano tiles with PyAutoGUI
# -*- coding: utf-8 -*-
"""
@author: Saurav Kanchan
"""
import pyautogui as pt
import time
time.sleep(5)
pt.FAILSAFE = True
@SauravKanchan
SauravKanchan / scrapy.py
Created September 18, 2017 18:13
Crawling web pages with scrapy
import scrapy
crawled=set('https://ves.ac.in/')
class MySpider(scrapy.Spider):
name = 'my_spider'
allowed_domains = ['ves.ac.in']
def start_requests(self):yield scrapy.Request("https://ves.ac.in/",self.parse)
def parse(self, response):
for url in response.xpath('//a/@href').extract():
if url not in crawled:
crawled.add(url)
@SauravKanchan
SauravKanchan / sudoku_solver.py
Created September 20, 2017 10:07
Sudoku Solver wriiten in python
cell=[]
[cell.append(list(map(int,input().split()))) for _ in range(9)]#Take the given sudoku.
def Blank():#Search for blank(or 0's) in cell.Give cordinate of blank cell.
for i in range(0, 9):
for j in range(0, 9):
if cell[i][j] == 0:
return [i, j]
return [-1, -1]
import pandas as pd
import numpy as np
import glob
import xlsxwriter
from math import isnan
workbook = xlsxwriter.Workbook('report.xlsx')
worksheet = workbook.add_worksheet()
all_data = pd.DataFrame()
# Setting Up hyperledger fabric dev servers
$ mkdir ~/fabric-tools && cd ~/fabric-tools
$ curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.zip
$ unzip fabric-dev-servers.zip
$ mkdir ~/fabric-tools && cd ~/fabric-tools
$ curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz
$ tar xzf fabric-dev-servers.tar.gz
export FABRIC_VERSION=hlfv11
$ cd ~/fabric-tools
@SauravKanchan
SauravKanchan / wallet.js
Created July 26, 2019 11:04
ethers + bip39
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).bip39=e()}}(function(){return function(){return function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var l=r[s]={exports:{}};t[s][0].call(l.exports,function(e){var r=t[s][1][e];return i(r||e)},l,l.exports,e,t,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}}()({1:[function(e,t,r){var n=e("safe-buffer").Buffer,i=e("stream").Transform,o=e("string_decoder").StringDecoder;function s(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._fina
pragma solidity ^0.5.0;
contract ERC20 {
using SafeMath for uint256;
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
event Transfer(address indexed from, address indexed to, uint tokens);
mapping(address => uint256) balances;
mapping(address => mapping (address => uint256)) allowed;
string public symbol;
const path = require('path');
const fs = require('fs-extra');
const solc = require('solc');
const sourceFolderPath = path.resolve(__dirname, 'contracts');
const buildFolderPath = path.resolve(__dirname, 'build');
const getContractSource = contractFileName => {
const contractPath = path.resolve(__dirname, 'contracts', contractFileName);
const startTimestamp = Date.now();
const ethers = require('ethers');
const config = require('./config.json');
const fs = require('fs-extra');
const provider = ethers.getDefaultProvider(config["network"]);
const wallet = new ethers.Wallet(config["private_key"], provider);
console.log(`Loaded wallet ${wallet.address}`);
{
"name": "ethers-template",
"version": "1.0.0",
"description": "",
"main": "webpack.config.js",
"scripts": {
"deploy": "node compile.js && node deploy.js ERC20",
"build": "webpack --mode production",
"test": "echo \"Error: no test specified\" && exit 1"
},