Skip to content

Instantly share code, notes, and snippets.

View codenoid's full-sized avatar

codenoid

View GitHub Profile
@codenoid
codenoid / vapor.gif
Created October 30, 2019 15:36 — forked from xiel/vapor.1.gif
vapor.gif
@codenoid
codenoid / vapor.gif
Last active October 30, 2019 15:34 — forked from mathdroid/vapor.1.gif
vapor.gif
@codenoid
codenoid / cvimg.py
Created January 12, 2018 09:28 — forked from tonmoay/cvimg.py
Template matching using OpenCV python. This code gets a real time frame from webcam & matches with faces in 'images' folder. After the lookup, it rectangles the webcam face & says with which face the webcam face matches
import cv2
from matplotlib import pyplot as plt
import numpy as np
cap = cv2.VideoCapture(0) #Webcam Capture
while(True):
ret, frame = cap.read()
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
@codenoid
codenoid / matchmacro.nim
Created September 11, 2017 07:18 — forked from mashingan/matchmacro.nim
defining match syntax using Nim macro
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
# 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
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 }
@codenoid
codenoid / server.cr
Created August 13, 2017 01:33 — forked from solisoft/server.cr
multi rooms kemal websockets server
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