Skip to content

Instantly share code, notes, and snippets.

import cv2
# find intersection percentage between to images
def find_intersection_percent(im1_path, im2_path):
im1 = cv2.imread(im1_path, cv2.IMREAD_UNCHANGED)
_, mask1 = cv2.threshold(im1[:, :, 3], 1, 255, cv2.THRESH_BINARY)
cv2.imwrite('im1-mask.png', mask1)
im2 = cv2.imread(im2_path, cv2.IMREAD_UNCHANGED)
_, mask2 = cv2.threshold(im2[:, :, 3], 1, 255, cv2.THRESH_BINARY)
# https://www.geeksforgeeks.org/opencv-alpha-blending-and-masking-of-images/
import cv2
im = cv2.imread("black glasses.png", cv2.IMREAD_UNCHANGED)
_, mask = cv2.threshold(im[:, :, 3], 1, 255, cv2.THRESH_BINARY)
cv2.imwrite('mask1.jpg', mask)
@tuncatunc
tuncatunc / deploy.js
Created June 17, 2021 19:31
Hardhat deploy script to deploy UniswapV2Factory, and create token pairs.
// We require the Hardhat Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through `node <script>`.
//
// When running the script with `hardhat run <script>` you'll find the Hardhat
// Runtime Environment's members available in the global scope.
const hre = require("hardhat");
async function main() {
// Hardhat always runs the compile task when running scripts with its command
// line interface.
@tuncatunc
tuncatunc / SDLC notes.md
Last active March 24, 2019 20:15
SDLC notes

Definition

SDLC is a process followed for a software project.

Stages

1 Planning and Requirement Analysis

  • Inputs from marketting, sales, domain experts
  • Feasibility analysis
  • Risk identification
  • Output of technical feasibility is to identify technical approaches to implement project with minimum risks

2 Define requirements

  • Define product requirements and get them approved by customer/s
@tuncatunc
tuncatunc / ipNormalize.js
Last active December 1, 2017 11:31
ipMasking with redux-form Field component normalize
const ipNormalize = (value, prev, values, prevValues) => {
let length = value.length
let index = value.lastIndexOf('.') + 1
let noOfDots = value.split('.').length -1
let updatedVal = ''
if (length !== index && noOfDots < 3 && prev.length < length && (length - index) % 3 == 0) {
updatedVal = value + '.'
}
else if (noOfDots > 3 || length - index > 3){
let newString = value.substring(0, length - 1)
@tuncatunc
tuncatunc / location-history.json
Created August 17, 2017 04:52
Location History sample taken from Google Takeout
{
"locations" : [ {
"timestampMs" : "1502634710304",
"latitudeE7" : 409910142,
"longitudeE7" : 291707583,
"accuracy" : 110
}, {
"timestampMs" : "1502634632322",
"latitudeE7" : 409953152,
"longitudeE7" : 291529541,
const fs = require('fs')
const JSONStream = require('JSONStream');
var es = require('event-stream');
const filePath = './location-history.json'
const fileOutputPath = './transform-location-history.js'
const fileStream = fs.createReadStream(filePath);
const fileOutputStream = fs.createWriteStream(fileOutputPath)
let index = 0;