This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# bash script to generate tree structure of a directory | |
# Pravendra Singh (@hackpravj) | |
pwd=$(pwd) | |
find $pwd -print | sed -e "s;$pwd;\.;g;s;[^/]*\/;|__;g;s;__|; |;g" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python 3 program to find the stem | |
# of given list of words | |
# function to find the stem (longest | |
# common substring) from the string array | |
def findstem(arr): | |
# Determine size of the array | |
n = len(arr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"name": "sample 1", "image": "url 1"}, {"name": "sample 2", "image": "url 2"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var i = 99 | |
while i > 0 | |
println(i + " bottles of beer on the wall, " + i + "bottles of beer.") | |
var num = i - 1 | |
if i == 1 { | |
var num = "no more" | |
} | |
println("Take one down and pass it around, " + num + "bottles of beer on the wall.") | |
println("No more bottles of beer on the wall, no more bottles of beer.") | |
println("Go to the store and buy some more, 99 bottles of beer on the wall.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
# grayscale version of the single color image | |
image_gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) | |
# bilateral filter is effective when you want to | |
# keep the edges sharp while removing noise | |
image_gray = cv2.bilateralFilter(image_gray, 10, 50, 50) | |
# find contour in gray scale image after applying erosion and dilation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference: https://code.likeagirl.io/finding-dominant-colour-on-an-image-b4e075f98097 | |
from sklearn.cluster import KMeans | |
# word block colors (color palette) | |
block_colors = [] | |
# change dimension to (width x height, color-channels) | |
screen = screen.reshape((screen.shape[0] * screen.shape[1], 3)) | |
# Collect 8 major colors in the image using KMeans clustering |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gensim.models.keyedvectors import KeyedVectors | |
# load local word2vec model | |
model = KeyedVectors.load_word2vec_format( | |
os.getenv('SEMANTRIS_SOLVER_WORD2VEC_PATH'), | |
binary=True | |
) | |
# list of tuples containing the word and similarity score | |
associated_word_tuples = model.most_similar(word, topn=20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytesseract | |
image_text = pytesseract.image_to_string(cropped_image) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
# load and find the dimension attritbutes of the template image | |
template_img = cv2.imread('./gray-template.png', 0) | |
w, h = template_img.shape[::-1] | |
# OpenCV's template matching method | |
res_img = cv2.matchTemplate( | |
screen2, template_img, cv2.TM_CCOEFF_NORMED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import pyautogui | |
# using a screen size specific region | |
screen = pyautogui.screenshot(region=(200, 100, 1000, 700)) | |
screen_img_gray = cv2.cvtColor(np.array(screen), cv2.COLOR_RGB2GRAY) |
NewerOlder