Skip to content

Instantly share code, notes, and snippets.

Avatar

Ari Gesher arigesher

View GitHub Profile
View overlay_alpha_image_precise.py
import numpy as np
import cv2
def overlay_alpha_image_lazy(background_rgb, overlay_rgba, alpha):
# cf https://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending
# If the destination background is opaque, then
# out_rgb = overlay_rgb * overlay_alpha + background_rgb * (1 - overlay_alpha)
overlay_alpha = overlay_rgba[: , : , 3].astype(np.float) / 255. * alpha
overlay_alpha_3 = np.dstack((overlay_alpha, overlay_alpha, overlay_alpha))
overlay_rgb = overlay_rgba[: , : , : 3].astype(np.float)
@arigesher
arigesher / find_value.coffee
Last active Aug 29, 2015
Snippet to recursively search a JSON structure for a leaf value - returns the path
View find_value.coffee
find_value = (haystack, needle, cache=new WeakMap()) ->
# console.log "haystack: ", haystack
# console.log "needle: ", needle
try
if haystack?
unless typeof haystack == 'object' and cache.has haystack
cache.set haystack, true
for key, value of haystack
@staltz
staltz / introrx.md
Last active Oct 3, 2022
The introduction to Reactive Programming you've been missing
View introrx.md
@sbentzen
sbentzen / Things-Migration.applescript
Created Feb 25, 2012
Things to Things Migration
View Things-Migration.applescript
---------
-- Convert Things database to Things Beta database.
-- This script clones all area's, projects, people and tasks with all its relations, properties and correct ordering without any duplicates.
-- * 25 November 2011: Initial version.
-- * 26 November 2011: Removed some linefeeds to make it better readable on the forum.
-- * 27 November 2011: Fixed bug in addTask where activation was set in error.
--
-- TODO:
-- * Preserve log dates of completed tasks in the logbook. (I really want this, but think it isn't possible according to the current Things AppleScipt Guide?)
-- * Preserve repeating schedules. (I think this isn't possible either?)