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 / MEMOIZE.md
Last active December 2, 2024 00:15
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
//
// YeetJSIUTils.h
// yeet
//
// Created by Jarred WSumner on 1/30/20.
// Copyright © 2020 Facebook. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <jsi/jsi.h>
@derekstavis
derekstavis / FastList.tsx
Last active August 7, 2024 10:09 — forked from vishnevskiy/FastList.js
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";
@axemclion
axemclion / JSIObject.cpp
Last active October 4, 2023 19:36
React Native JSI Example
// This sample is a Work in Progress for JSI , and specific functions may change.
#pragma once
#include <string>
#include <unordered_map>
#include <jsi/jsi.h>
// This SameplJSIObject needs to inheric from HostObject, and this is the object that will be exposed to JS.
@mrousavy
mrousavy / AnimationExtensions.cs
Created August 21, 2017 10:23
Useful async extensions for WPF UIElements/Animatable for animating with ease
using System;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Animation;
namespace mrousavy {
public static class AnimationExtensions {
/// <summary>
/// Animate a given <see cref="UIElement" />/<see cref="System.Windows.Controls.Control" /> asynchronous (awaitable)
/// </summary>
@chourobin
chourobin / 0-bridging-react-native-cheatsheet.md
Last active December 18, 2024 16:22
React Native Bridging Cheatsheet
@danielpi
danielpi / OSTypedEnum.swift
Created March 27, 2017 13:29
Extension to AVCaptureVideoDataOutput and an enum to represent OSType CVPixelFormatType data
extension AVCaptureVideoDataOutput {
var availableVideoCVPixelFormatTypedEnums: [OSTypedEnum] {
let availablePixelFormatDescriptions: Array<OSType> = self.availableVideoCVPixelFormatTypes as! Array<OSType>
let availablePixelFormats: Array<OSTypedEnum> = availablePixelFormatDescriptions.map { OSTypedEnum(rawValue: $0)! }
return availablePixelFormats
}
}
enum OSTypedEnum: OSType {
case monochrome1 = 1

How to add an image to a gist

  1. Create a gist if you haven't already.
  2. Clone your gist:
    # make sure to replace `<hash>` with your gist's hash
    git clone https://gist.github.com/<hash>.git # with https
    git clone git@gist.github.com:<hash>.git     # or with ssh
@mrousavy
mrousavy / Loom.cs
Created January 23, 2017 12:53
XYZ Loom for Unity 3D/2D
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using System.Threading;
using System.Linq;
[ExecuteInEditMode]
/// <summary>
/// Multithreading support
@mrousavy
mrousavy / GetScreenshot.cs
Created January 9, 2017 15:22
Get Image from whole screen (BitmapSource)
public class GetScreenshot{
public static BitmapSource GetScreen(Rectangle coordinates) {
int left = coordinates.Left;
int top = coordinates.Top;
int width = coordinates.Width;
int height = coordinates.Height;
using(var screenBmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)) {
using(var bmpGraphics = Graphics.FromImage(screenBmp)) {