Skip to content

Instantly share code, notes, and snippets.

View dalcib's full-sized avatar

Dalci de Jesus Bagolin dalcib

View GitHub Profile
@EvanBacon
EvanBacon / metro-transformer.js
Created December 22, 2021 20:31
Using Realm with Expo Metro config "Exotic" bundling.
const { createExoticTransformer } = require("@expo/metro-config/transformer");
module.exports = createExoticTransformer({
// Add realm packages to the list of modules to transpile locally.
transpileModules: ["@realm/", "realm"],
});
@yyx990803
yyx990803 / exampe-config.js
Created January 13, 2021 02:58
A vite plugin that loads the specified deps over CDN during dev, and downloads/includes them into bundle during build.
// example vite.config.js
import { cdn } from './vite-plugin-cdn'
export default {
plugins: [
// also supported: esm.run, jspm
// loads the dep over the CDN during dev
// auto downloads and includes into the bundle during build
cdn('skypack', {
vue: '^3.0.5'
@mtgto
mtgto / serve.mjs
Last active August 25, 2023 03:10
Hot reload and do incremental builds with `esbuild`
/*
* Change from https://gist.github.com/unki2aut/4ac81c33be2e8f121e80a26eba1735d7
* - Use top level await (Node.js v14.8.0+)
* - To use top level await, you need to write a script as ES Modules
* - Set chokidar options to avoid duplicate building
* - Define NODE_ENV (For React)
* - Add API proxy setting by using proxy-middleware
*/
import chokidar from "chokidar";
import esbuild from "esbuild";
@ClickerMonkey
ClickerMonkey / types.ts
Last active August 8, 2024 00:25
Typescript Helper Types
// when T is any|unknown, Y is returned, otherwise N
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N;
// when T is never, Y is returned, otherwise N
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N;
// when T is a tuple, Y is returned, otherwise N
// valid tuples = [string], [string, boolean],
// invalid tuples = [], string[], (string | number)[]
const fs = require("fs");
const bundle = fs.readFileSync("path-to-webpack-bundle.html", "utf8");
const escaped = JSON.stringify(bundle);
const js = `export default ${escaped}`;
fs.writeFileSync("javascript-output-file.ts", js);
@kstulgys
kstulgys / index.js
Last active October 14, 2019 10:53
import React, { useMemo, useContext, createContext } from "react"
import { useImmer } from "use-immer"
const initialState = {
count: 0
}
function makeStore() {
const Context = createContext()
@tgriesser
tgriesser / formik.tsx
Last active March 12, 2021 10:58
Formik w/ Hooks
import React, {
useContext,
createContext,
createElement,
useEffect,
useRef,
useCallback,
useState,
} from 'react';
import isEqual from 'react-fast-compare';
@DimitryDushkin
DimitryDushkin / configs.js
Created October 2, 2018 14:19
React Native 0.57 + Babel 7 + Typescript + Jest
// babel.config.js
module.exports = {
"presets": [
"module:metro-react-native-babel-preset",
],
"plugins": [
["module-resolver", {
"root": ["./src"],
"extensions": [".js", ".ts", ".tsx", ".ios.js", ".android.js"]
}],
@doomsower
doomsower / react-native-paper.d.ts
Created August 26, 2018 13:30
react-native-paper.d.ts
// tslint:disable:max-classes-per-file
declare module 'react-native-paper' {
import { Component, ReactNode } from 'react';
import {
StyleProp,
TextProps,
TextStyle,
TouchableHighlightProps,
TouchableNativeFeedbackProps,
ViewProps,