Skip to content

Instantly share code, notes, and snippets.

@evelant
evelant / textdecoder.js
Created May 7, 2024 19:24
fastestsmallesttextencoderdecoder TextDecoder polyfill fixed for react-native 0.74
(function(window){
"use strict";
var log = Math.log;
var LN2 = Math.LN2;
var clz32 = Math.clz32 || function(x) {return 31 - log(x >>> 0) / LN2 | 0};
var fromCharCode = String.fromCharCode;
var Object_prototype_toString = ({}).toString;
var NativeSharedArrayBuffer = window["SharedArrayBuffer"];
var sharedArrayBufferString = NativeSharedArrayBuffer ? Object_prototype_toString.call(NativeSharedArrayBuffer) : "";
var NativeUint8Array = window.Uint8Array;
import {
Span as SentrySpan,
SpanStatusType,
getActiveSpan,
getActiveTransaction,
getCurrentHub,
startSpanManual,
startTransaction,
} from "@sentry/core"
import type * as Sentry from "@sentry/types"
@evelant
evelant / gist:c7d2b79af62a3864771d63c4d53a1d9a
Last active December 18, 2023 19:02
Frame aware scheduler for Effect
class FrameAwareReactScheduler implements Scheduler.Scheduler {
tasks: Array<Scheduler.Task> = []
scheduledRaf: number | undefined = undefined
constructor(readonly maxMsBeforeFrame: number) {}
isRunning = false
scheduleFrame() {
if (this.scheduledRaf === undefined && !this.isRunning) {
this.scheduledRaf = requestAnimationFrame(() => {
this.isRunning = true
@evelant
evelant / DateUtils.ts
Created September 6, 2023 15:02
DateUtils
import { closestTo } from "date-fns"
import _ from "lodash"
const SECONDS = 1000
const MINUTES = SECONDS * 60
const HOURS = MINUTES * 60
const DAYS = HOURS * 24
const YEARS = DAYS * 365
/**
This file has been truncated, but you can view the full file.
imagio  …/rn072-pnpm-monorepo-ios-frameworks-static-bug/apps/testproj   main   v18.16.0  ♥ 10:38  pnpm react-native run-ios
info Found Xcode workspace "testproj.xcworkspace"
info Found booted iPhone SE (3rd generation)
info Launching iPhone SE (3rd generation)
info Building (using "xcodebuild -workspace testproj.xcworkspace -configuration Debug -scheme testproj -destination id=E0322BB3-B552-4E9E-8E9A-F31C896CA903")
info 💡 Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening testproj.xcworkspace.
Command line invocation:
@evelant
evelant / managed_runtime.ts
Created January 31, 2023 22:06
Global effect runtime for use with react(-native)
/**
* Example of a "global managed runtime" for use with react(-native)
* React isn't a traditional zio/effect app that has one entry point
* There may be many effects run but we don't want to reconstruct all our app services each
* time we want to run an effect.
*
* This code builds app services layers just once then provides a global runtime object that can
* be used to run as many effects as you want all with access to the same service instances.
*
* ex:
Object {
"_id": RuntimeFiberId {
"_tag": "Runtime",
"id": 51,
"startTimeSeconds": 1661444456,
Symbol(@effect/core/io/FiberId): Symbol(@effect/core/io/FiberId),
},
"state": AtomicReference {
"current": Executing {
"_tag": "Executing",
-- minishift version: v1.33.0+ba29431
-- Starting profile 'minishift'
Found binary path at /usr/local/bin/docker-machine-driver-xhyve
Launching plugin server for driver xhyve
Plugin server listening at address 127.0.0.1:52310
() DBG | operation not supported by device
() Calling .GetVersion
Using API Version 1
() Calling .SetConfigRaw
() Calling .GetMachineName
Graphics Feature Status
Canvas: Hardware accelerated
Flash: Hardware accelerated
Flash Stage3D: Hardware accelerated
Flash Stage3D Baseline profile: Hardware accelerated
Compositing: Hardware accelerated
Multiple Raster Threads: Enabled
Native GpuMemoryBuffers: Hardware accelerated
Out-of-process Rasterization: Disabled
I20160517-15:28:37.624(-4)? MochaRunner.runServerTests: Starting server side tests with run id mGR8a5HXutcZ88Zq4
W20160517-15:28:37.662(-4)? (STDERR) MeteorPublishReporter.added: Can't send report data to client.
W20160517-15:28:37.663(-4)? (STDERR) MeteorPublishReporter.added: Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
W20160517-15:28:37.665(-4)? (STDERR) MeteorPublishReporter.added: Document: { _id: '4',
W20160517-15:28:37.665(-4)? (STDERR) event: 'suite',
W20160517-15:28:37.666(-4)? (STDERR) data:
W20160517-15:28:37.666(-4)? (STDERR) { title: 'test',
W20160517-15:28:37.667(-4)? (STDERR) root: false,
W20160517-15:28:37.667(-4)? (STDERR) pending: false,
W20160517-15:28:37.667(-4)? (STDERR) _fullTitle: 'test',