Skip to content

Instantly share code, notes, and snippets.

@stevengoldberg
stevengoldberg / Example.js
Last active May 28, 2025 17:09
Expo Module wrapper for Mantis iOS cropping library
function CropperExample({
image,
cropperRef,
isCroppingLocked,
setIsCroppingLocked,
setCroppingRatio,
setIsCropResettable,
}) {
return (
<CropperView
@stevengoldberg
stevengoldberg / lut-image.js
Created May 21, 2025 14:06
Applying a LUT texture with skia
import {
Skia,
TileMode,
FilterMode,
MipmapMode,
} from '@shopify/react-native-skia'
export function renderLUTImage({
baseImage,
lutImage,
/*
-------------------------------------------------------------
* decodeAsync → renders RAW to PNG using minimal processing
• applies BaselineExposure
• localToneMapAmount interpolated from measuredDR()
* extractPreview → extracts embedded JPEG preview, writes to tmp, returns {uri,width,height}
* CIRAW defaults: gamutMapping ON, lensCorrection ON, boostAmount 0, all noise‑reduction 0
* isPreview flag maps to CIRAWFilter.isDraftModeEnabled
*/
@stevengoldberg
stevengoldberg / App.ts
Last active January 25, 2025 17:40
Expo Module for listening to media library changes
import { AppState } from 'react-native'
import { useRef, useEffect } from 'react'
const App = () => {
const appState = useRef(AppState.currentState)
useEffect(() => {
const appStateSubscription = AppState.addEventListener(
'change',
@stevengoldberg
stevengoldberg / bst.js
Last active March 16, 2020 13:02
ES6 functions for manipulating a Binary Search Tree
/*
* Based on the work of Nicholas C. Zakas
* https://github.com/nzakas/computer-science-in-javascript/
*/
class Node {
constructor(value = null, left = null, right = null) {
this.value = value;
this.right = right;
this.left = left;
@stevengoldberg
stevengoldberg / nthMax.js
Last active August 29, 2015 14:27
An ES6 utility function for finding the nth-max value in an array
/**
* An ES6 utility function for finding the nth-max value in an array.
*/
let nthMax = (array, nth = 1) => {
if(nth > (array.length - 1)) {
throw new Error('Nth max value exceeds array size');
}
let newArr = array,
i = 0;