Skip to content

Instantly share code, notes, and snippets.

View JoshuaGross's full-sized avatar

Joshua Gross JoshuaGross

View GitHub Profile
@DavidYKay
DavidYKay / simple_cb.py
Last active February 13, 2025 13:54
Simple color balance algorithm using Python 2.7.8 and OpenCV 2.4.10. Ported from: http://www.morethantechnical.com/2015/01/14/simplest-color-balance-with-opencv-wcode/
import cv2
import math
import numpy as np
import sys
def apply_mask(matrix, mask, fill_value):
masked = np.ma.array(matrix, mask=mask, fill_value=fill_value)
return masked.filled()
def apply_threshold(matrix, low_value, high_value):
@chantastic
chantastic / on-jsx.markdown
Last active November 10, 2024 13:39
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@tvlooy
tvlooy / unit.sh
Last active May 4, 2025 03:31
Bash test: get the directory of a script
#!/bin/bash
function test {
MESSAGE=$1
RECEIVED=$2
EXPECTED=$3
if [ "$RECEIVED" = "$EXPECTED" ]; then
echo -e "\033[32m✔︎ Tested $MESSAGE"
else
@stuarteberg
stuarteberg / superpixel-stack-to-body-label-volume.py
Last active September 25, 2017 20:50
Read a stack of superpixel .png files (exported from Raveler), relabel them, and export the volume as hdf5.
"""
Utility function relabel_superpixels_to_bodies(), along with a main() function providing a command-line interface.
See usage documentation in main(), below.
"""
from __future__ import print_function
import collections
import numpy as np
import vigra
def main():
@telekosmos
telekosmos / uniq.js
Last active November 15, 2022 17:13
Remove duplicates from js array (ES5/ES6)
var uniqueArray = function(arrArg) {
return arrArg.filter(function(elem, pos,arr) {
return arr.indexOf(elem) == pos;
});
};
var uniqEs6 = (arrArg) => {
return arrArg.filter((elem, pos, arr) => {
return arr.indexOf(elem) == pos;
});
@paulirish
paulirish / what-forces-layout.md
Last active May 5, 2025 08:05
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
var Col = require('react-bootstrap/lib/Col')
var PageHeader = require('react-bootstrap/lib/PageHeader')
var React = require('react')
var Row = require('react-bootstrap/lib/Row')
var {connect} = require('react-redux')
var {reduxForm} = require('redux-form')
var DateInput = require('./DateInput')
var FormField = require('./FormField')
var LoadingButton = require('./LoadingButton')
@fnoble
fnoble / sdiff_empty.c
Last active September 22, 2016 21:52 — forked from mookerji/sdiff_empty.c
single diff measurement question (intersection of two structs via prns)
// Compiles with gcc -O0 single_diff_libswiftnav.c
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <inttypes.h>
typedef uint8_t u8;
typedef uint16_t u16;
@JoshuaGross
JoshuaGross / normalize-json.sh
Last active December 11, 2015 02:09
Sort JSON to make it easier to diff two JSON blobs by normalizing whitespace, alphabetization of dictionaries.
# Install:
npm install -g sort-json
# Put this in your ~/.profile, and then:
# cat something.json | normalize_json
alias normalize_json="node -e 'var s = \"\"; process.stdin.on(\"data\", function (d) { s += d.toString(); }); process.stdin.resume(); process.on(\"exit\", function() { console.log(JSON.stringify(require(\"sort-json\")(JSON.parse(s)), null, 2)); });'"
@bishboria
bishboria / springer-free-maths-books.md
Last active March 24, 2025 13:36
Springer made a bunch of books available for free, these were the direct links