Skip to content

Instantly share code, notes, and snippets.

View arigesher's full-sized avatar

Ari Gesher arigesher

View GitHub Profile
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 August 29, 2015 14:25
Snippet to recursively search a JSON structure for a leaf value - returns the path
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 March 26, 2024 00:52
The introduction to Reactive Programming you've been missing
@sbentzen
sbentzen / Things-Migration.applescript
Created February 25, 2012 00:37
Things to Things Migration
---------
-- 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?)