Skip to content

Instantly share code, notes, and snippets.

View mrousavy's full-sized avatar
🐍
slime season

Marc Rousavy mrousavy

🐍
slime season
View GitHub Profile
@mrousavy
mrousavy / a.gif
Last active July 26, 2020 09:49
a.gif
@mrousavy
mrousavy / magic.ts
Last active September 14, 2020 09:35
TypeScript: Omit parameter using generics (e.g. useful for navigation commands with optional parameters)
interface StoryView {
onStoryPressed: <TStory extends UserStory | CategoryStory>(
...args: TStory extends UserStory ? [stories: Story[], selectedStory: UserStory, user: User] : [stories: Story[], selectedStory: CategoryStory]
) => void;
}
@mrousavy
mrousavy / lottie-react-native+3.5.0.patch
Created February 8, 2021 14:07
A patch for lottie-react-native so it successfully builds with React Native 0.64
diff --git a/node_modules/lottie-react-native/lottie-react-native.podspec b/node_modules/lottie-react-native/lottie-react-native.podspec
index 006d118..63caf4a 100644
--- a/node_modules/lottie-react-native/lottie-react-native.podspec
+++ b/node_modules/lottie-react-native/lottie-react-native.podspec
@@ -14,7 +14,11 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/react-community/lottie-react-native.git", :tag => "v#{s.version}" }
s.source_files = "src/ios/**/*.{h,m,swift}"
- s.swift_version = "5.0"
- s.dependency 'React'
@mrousavy
mrousavy / FastList.tsx
Created March 17, 2021 12:37 — forked from derekstavis/FastList.tsx
Discord's FastList, but in TypeScript
import { forEachObjIndexed } from "ramda";
import * as React from "react";
import {
Animated,
ScrollView,
View,
ViewStyle,
LayoutChangeEvent,
NativeScrollEvent,
} from "react-native";
@mrousavy
mrousavy / MEMOIZE.md
Last active April 18, 2026 14:22
Memoize!!! 💾 - a react (native) performance guide
In computing, memoization or memoisation
is an optimization technique used primarily
to speed up computer programs by storing
the results of expensive function calls and  
returning the cached result when the same
inputs occur again.                                         
                                                     — wikipedia
@mrousavy
mrousavy / useStyle.ts
Last active August 1, 2023 13:16
`useStyle` - a typed `useMemo` for styles which also includes style flattening and searching
import { DependencyList, useMemo } from "react";
import {
ImageStyle,
RegisteredStyle,
StyleProp,
StyleSheet,
TextStyle,
ViewStyle,
} from "react-native";
@mrousavy
mrousavy / ghost.md
Created March 30, 2021 18:55
👻👻👻

SVG Banners

@mrousavy
mrousavy / oss.md
Last active April 8, 2021 13:10
maintaining open-source software is hard.

SVG Banners

@mrousavy
mrousavy / fastReverse.ts
Last active January 28, 2022 22:59
A JS function that returns a copy of the input Array in reversed order
/**
* Returns a reversed copy of the given Array
*/
export function fastReverse<T>(arr: T[]): T[] {
const result = new Array<T>(arr.length);
for (let i = 0; i < arr.length; i++) {
result[i] = arr[arr.length - 1 - i];
}
return result;
};
@mrousavy
mrousavy / settings.json
Last active September 9, 2021 19:59
My VSCode settings + themes + extensions
// VSCode Settings (hit `Cmd + ,` to open settings)
{
"editor.smoothScrolling": true,
"editor.fontSize": 16,
"editor.fontFamily": "Fira Mono, Consolas, 'Courier New', monospace",
"editor.wordWrap": "on",
"editor.tabCompletion": "on",
"explorer.openEditors.visible": 0,
"explorer.autoReveal": false,