Skip to content

Instantly share code, notes, and snippets.

View anupam-io's full-sized avatar
Coffee

anupam anupam-io

Coffee
  • Range Security
  • Bangalore
  • 03:41 (UTC +05:30)
View GitHub Profile
@anupam-io
anupam-io / compileAll.js
Last active January 5, 2021 09:59
Compile scripts for solidity
var path = require('path');
var solc = require('solc');
var fs = require('fs-extra');
const buildPath = path.resolve(__dirname, 'build');
fs.removeSync(buildPath);
fs.mkdirSync(buildPath);
fs.readdir(path.resolve(__dirname, 'contracts'), function (err, files) {
//listing all files using forEach
@anupam-io
anupam-io / deploy_ganache.js
Last active January 5, 2021 10:00
Deploy scripts for solidity with web3 and wallet/ganache
const Web3 = require('web3');
const compiledContract = require('./../build/MyContract.json');
const rpcEndpoint = 'rpc-END-POINT';
// you will get from ganache-GUI
// Setting up the provider
const provider = new Web3.providers.HttpProvider(rpcEndpoint);
const web3 = new Web3(provider);
@anupam-io
anupam-io / main.py
Created February 5, 2021 11:07
Live animation from X and Y values in Python
import matplotlib.pyplot as plt
import numpy as np
import time
from random import randint
n = 10
x = []
y = []
plt.ion()
@anupam-io
anupam-io / main.py
Created February 7, 2021 15:19
GapFinder animation with matplotlib
import matplotlib.pyplot as plt
from random import randint, uniform
plt.rcParams['figure.figsize'] = [10, 6]
n = 20
x = [uniform(0, 100) for i in range(n)] # x axis position
y = [uniform(0, 100) for i in range(n)] # y axis position
rad = [uniform(0, 1000) for i in range(n)] # radius of the circle
cat = [randint(1, 5) for i in range(n)] # category
@anupam-io
anupam-io / main.py
Created February 10, 2021 06:28
Testing various approaches of iterating through python lists using indexes
from time import time
n = 10**4
arr = [i for i in range(n)]
def test_fun(i):
# some compuatations
a =0
b =0
a+=arr[i]*arr[i]*arr[i]*arr[i]*arr[i]*arr[i]
b+=arr[i]+arr[i]+arr[i]+arr[i]+arr[i]+arr[i]
@anupam-io
anupam-io / main.sql
Created February 15, 2021 07:32
How to set custom values instead of NULL in outer joins?
drop database if exists db;
create database db;
use db;
drop table if exists a,b;
create table a(attr1 varchar(50), score int(10));
insert into a (attr1, score)values
("info1", 1), ("info2", 2);
@anupam-io
anupam-io / rm.sql
Created February 19, 2021 16:35
Downgrade mysql settings for testing.
SET GLOBAL validate_password.length = 4;
SET GLOBAL validate_password.mixed_case_count = 0;
SET GLOBAL validate_password.number_count = 0;
SET GLOBAL validate_password.policy = LOW;
SET GLOBAL validate_password.special_char_count = 0;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';
@anupam-io
anupam-io / ditw.md
Created February 20, 2021 14:14
Delving into the white paper series
@anupam-io
anupam-io / flatten.py
Last active February 22, 2021 09:11
Flattening a colored image by converting into grayscale
import numpy as np
import cv2
img = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE)
img = cv2.resize(img, (20, 20))
img = np.array(img).ravel()
img = img.reshape(-1)
print(img)
@anupam-io
anupam-io / main.py
Created February 27, 2021 10:44
Voice logging function in Python using gTTS
def vlog(s):
s = str(s)
from gtts import gTTS
from os import system
language = 'en'
output = gTTS(text=s, lang=language, slow=False)
system("mkdir -p .vlogs")
output.save("./.vlogs/output.mp3")
system("ffplay -nodisp -autoexit ./.vlogs/output.mp3 >/dev/null 2>&1")