

This file contains hidden or 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 | |
from matplotlib import pyplot as plt | |
import numpy as np | |
cap = cv2.VideoCapture(0) #Webcam Capture | |
while(True): | |
ret, frame = cap.read() |
This file contains hidden or 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
module Indexable(T) | |
def threadpool_map(workers : Int = 8, chunk_size : Int? = nil, &func : T -> R) forall T, R | |
mutex = Thread::Mutex.new | |
cs = chunk_size || (self.size**0.5).ceil.to_i | |
Array(R).build(self.size) do |result| | |
index = 0 | |
threads = Array.new(workers) { | |
Thread.new do | |
a = b = 0 | |
loop do |
This file contains hidden or 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 macros | |
macro match(head, body: untyped): untyped = | |
result = newNimNode nnkStmtList | |
var casenode = newNimNode nnkCaseStmt | |
casenode.add head | |
for node in body: | |
node.expectKind nnkInfix |
This file contains hidden or 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
# Check your passwords against https://haveibeenpwned.com/Passwords | |
# Usage: | |
# crystal run --release check_passwords.cr -- pwned-passwords*.txt | |
# Enter your passwords one per line, then press Return twice | |
require "digest/sha1" | |
my_passwords = Hash(String, String).new | |
until (line = gets || "").empty? | |
my_passwords[Digest::SHA1.hexdigest(line).upcase] = line |
This file contains hidden or 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
require "kemal" | |
require "jwt" | |
require "json" | |
require "yaml" | |
require "arangocr" | |
require "redis" | |
# Load .env file | |
env_data = YAML.parse File.read(".env.yml") rescue Hash(String, String).new | |
env_data.each { |k, v| ENV[k.to_s] = v.to_s } |
This file contains hidden or 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
require "kemal" | |
require "arangocr" | |
require "json" | |
connected_sockets = {} of String => Array(HTTP::WebSocket) | |
connected_users = {} of String => Hash(String, JSON::Any) | |
def broadcast(data, sockets) | |
sockets.each do |socket| | |
socket.send data.to_json |