Skip to content

Instantly share code, notes, and snippets.

View soswow's full-sized avatar

Aleksandr Motsjonov soswow

View GitHub Profile
@soswow
soswow / histogram.py
Last active August 11, 2024 11:03
OpenCV and matplotlib driven script to display histogram for variety of file formats including raw like DNG, high dynamic range like EXR etc.
import cv2
import numpy as np
import matplotlib.pyplot as plt
import sys
import os
import argparse
os.environ["OPENCV_IO_ENABLE_OPENEXR"] = "true"
def generate_histogram(image_path, num_bins, y_scale, percentile, x_min, x_max):
@soswow
soswow / async-generator-directory-walk.ts
Created April 1, 2020 02:15
Async generator walk in nodejs
const extractSubNodeModules = async function*(
dir: string,
): AsyncGenerator<string, void, void> {
const files = await readdir(dir);
for (let i = 0; i < files.length; i++) {
const filepath = join(dir, files[i]);
const stats = await stat(filepath);
if (stats.isDirectory()) {
if (files[i] === 'node_modules') {
@soswow
soswow / LedCapProject.ino
Created November 15, 2018 04:50
LED Cap Project Arduino Project code
#include <Bounce2.h>
#include <FastLED.h>
#define BRIGHTNESS_PIN A6
#define NUM_LEDS 15
#define DATA_PIN 7
#define BUTTON_PIN 8
#define COLUMNS 6
#define ROWS 6
@soswow
soswow / designer.html
Created August 10, 2015 21:55
designer
<link rel="import" href="../topeka-elements/category-images.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<polymer-element name="my-element">
<template>
<style>
@soswow
soswow / loopy_buffer.coffee
Created April 7, 2014 18:33
My Solution for one company puzzle
class Node
constructor: (@data, @prev, @next) ->
@prev.next = this if @prev
@next.prev = this if @next
class LoopyBuffer
_head: null
_tail: null
_cursor: 0
size: 0
@soswow
soswow / fill_buckets.coffee
Last active August 29, 2015 13:57
You have 3 slots. You MUST fill each slot with one number. Each slot has list of possible numbers. Find best combination(s) that have total sum equal or closest to curtain limit.
_ = require 'underscore'
class BlackMagic
dp: null
dpMax: null
maxTotalWeight: 0
minTotalWeight: 0
minWeight: Number.MAX_VALUE
#global portviz:false, _:false
#
# * 0-1 knapsack solution, recursive, memoized, approximate.
# *
# * credits:
# *
# * the Go implementation here:
# * http://rosettacode.org/mw/index.php?title=Knapsack_problem/0-1
# *
@soswow
soswow / Gruntfile.js
Last active December 14, 2015 10:38
Middleware for handle pushState working inside yeoman development server.
// Generated on 2013-03-01 using generator-webapp 0.1.5
'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
var pushStateHook = function (url) {
var path = require('path');
var request = require('request'); // Need to be added into package.json