Skip to content

Instantly share code, notes, and snippets.

View cem2ran's full-sized avatar
⚛️
~ The only constant is change ~

Cem Turan cem2ran

⚛️
~ The only constant is change ~
View GitHub Profile
@sibelius
sibelius / useMemoArray.tsx
Created February 10, 2020 12:22
useMemo for arrays
const arrayCompare = (a: string[], b: string[]) => {
if (a.length !== b.length) {
return false;
}
for (const item of a) {
if (b.indexOf(item) === -1) {
return false;
}
}
@sibelius
sibelius / useRecursiveRefetch.tsx
Created February 3, 2020 20:08
Recursive fetch all items of a graphql connection using relay refetch container
import { useState, useEffect } from 'react';
import { RelayRefetchProp } from 'react-relay';
const TOTAL_REFETCH_ITEMS = 1000;
type PageInfo = {
hasNextPage: boolean;
startCursor: string | null;
endCursor: string | null;
};
@stettix
stettix / things-i-believe.md
Last active March 20, 2024 17:45
Things I believe

Things I believe

This is a collection of the things I believe about software development. I have worked for years building backend and data processing systems, so read the below within that context.

Agree? Disagree? Feel free to let me know at @JanStette. See also my blog at www.janvsmachine.net.

Fundamentals

Keep it simple, stupid. You ain't gonna need it.

@IanColdwater
IanColdwater / twittermute.txt
Last active April 22, 2024 17:26
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@sibelius
sibelius / NativeModules.js
Created December 3, 2019 20:49
react-native mock with SettingsManager
jest.mock('react-native/Libraries/BatchedBridge/NativeModules', () => ({
AlertManager: {
alertWithArgs: jest.fn(),
},
AsyncLocalStorage: {
multiGet: jest.fn((keys, callback) =>
process.nextTick(() => callback(null, [])),
),
multiSet: jest.fn((entries, callback) =>
process.nextTick(() => callback(null)),
@kelset
kelset / build-time-improvements.md
Last active June 21, 2023 19:25
This is kind of a blogpost about my experience of diving deep to improve some timings for an iOS React Native app

Improving times for both iOS build and CI for a React Native app

Intro

Hello there.

So, if you are here you probably saw my previous tweet where I asked for tips & tricks on improving the timing on an iOS/React Native app build time.

What will follow was how I mixed those suggestions + some good old GoogleSearch-fu + me deep diving on this for ~2 days.

final case class ZIO[-R, +E, +A](run: R => Either[E, A]) {
final def map[B](f: A => B): ZIO[R, E, B] =
ZIO(r => run(r).map(f))
final def flatMap[R1 <: R, E1 >: E, B](f: A => ZIO[R1, E1, B]): ZIO[R1, E1, B] =
ZIO(r => run(r).flatMap(a => f(a).run(r)))
final def provide(r: R): ZIO[Any, E, A] =
ZIO(_ => run(r))
module BigInt = {
type t = float;
[@bs.val] external ofString: string => t = "BigInt";
[@bs.val] external ofInt: int => t = "BigInt";
external (<): (t, t) => bool = "%lessthan";
external (<=): (t, t) => bool = "%lessequal";
external (>): (t, t) => bool = "%greaterthan";
external (>=): (t, t) => bool = "%greaterequal";
external (==): (t, t) => bool = "%equal";
@jordwalke
jordwalke / tutorial.md
Created October 2, 2019 20:54
Adding A ReHP backend quick tutorial.

Getting started with adding a backend for Rehp for a new language.

Let me know where you hit friction with these instructions and I'll clarify.

  • Clone rehp
  • grep -r php . to see various references to PHP. That shows you what was done to extend the compiler to add a new backend. You will be doing something very similar. In general, the best way to get started is to copy/paste everything that was done for PHP, to add your new backend.
  • Check out the file compiler/lib/rehp.re This is the new intermediate representation that was added to the jsoo compiler. Rehp uses the bytecode disassembler from jsoo, and instead of turning it into js, it turns it into this other intermediate representation called "Rehp"- which is defined bycompiler/lib/rehp.re`.
  • Add your backend to compiler/lib/backend.ml/i including info about the file extension.
  • Add a new file compiler/lib/YourLang.re, which can start out as a copy of the compiler/lib/php.re file. This represents the
@mattgperry
mattgperry / useAnimationLoop.js
Last active August 8, 2019 17:14
Use Framesync via a render loop
import sync, { cancelSync } from "framesync";
import { useEffect } from "react";
/**
The code inside useAnimationLoop is guaranteed to run once a frame
before Framer Motion/Popmotion/Pose renders
useAnimationLoop(({ delta, timestamp }) => {
// do stuff
})