Skip to content

Instantly share code, notes, and snippets.

@ChronSyn
ChronSyn / CustomText.tsx
Created May 7, 2020 15:43
CustomText component which can display expo google fonts. Direct replacement for Text from react-native
import * as React from "react";
import { Text, TextProps } from "react-native";
import { useFonts } from '@use-expo/font';
import {
Nunito_Regular400,
Nunito_SemiBold600_Italic,
} from '@expo-google-fonts/nunito';
const CustomText: React.FC<TextProps> = (props) => {
const [fontsLoaded] = useFonts({
@ChronSyn
ChronSyn / CustomText.tsx
Last active May 8, 2020 00:16
CustomText componnent for Expo - loads any google font
import * as React from "react";
import RN, { Text, TextProps } from "react-native";
import { Asset } from 'expo-asset';
import { useFonts } from '@use-expo/font';
import * as fonts from "@expo-google-fonts/dev";
enum FontDisplay {
AUTO = "auto",
SWAP = "swap",
@ChronSyn
ChronSyn / App.tsx
Last active December 29, 2020 00:38
React Navigation 5 - Multiple Navigator Handling
/*
IMPORTANT NOTE
The below is just an example showing how the root component of your project should be structured to support this multiple-navigator setup
You should adapt your app around it
*/
import React from "react";
@ChronSyn
ChronSyn / useTheme.ts
Last active February 15, 2021 01:41
React Native - useTheme hook
import { ITheme } from "@Themes/interfaces";
import { DarkTheme } from "@Themes/theme.dark";
import { LightTheme } from "@Themes/theme.light";
import React from "react";
import { useColorScheme } from "react-native-appearance";
export const useTheme = (): [ITheme] => {
const scheme = useColorScheme();
const [currentTheme, setCurrentTheme] = React.useState<ITheme>(DarkTheme);
@ChronSyn
ChronSyn / babel.config.js
Last active June 12, 2025 12:52
Expo - Alias path example
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
["@babel/plugin-transform-flow-strip-types"],
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }],
["module-resolver", {
"alias": {
@ChronSyn
ChronSyn / ShadowView.js
Created May 28, 2021 01:13 — forked from lletfrix/ShadowView.js
ShadowView.js
import React from 'react';
import { View, StyleSheet, Text, Dimensions, Platform } from 'react-native';
import Svg, { Circle, Rect, Defs, Use, Symbol, ForeignObject, LinearGradient, RadialGradient, Stop, G} from 'react-native-svg';
import { LinearGradient as LGradient } from 'expo-linear-gradient';
const Gauss = (x, sigma) => 1/(sigma * Math.sqrt(2*Math.PI)) * Math.exp( - (x**2) / (2*sigma**2 ))
const dot = (v1, v2) => v1.reduce( (acc, comp, idx) => (acc + comp*v2[idx]), 0)
const convolutions = (img, ker) => {
@ChronSyn
ChronSyn / ComponentExample.tsx
Last active November 5, 2021 22:00
MobX - useStores hook (Context)
import React from "react";
import { TouchableOpacity, Text } from "react-native";
import { observer } from "mobx";
import { useStores } from "../stores/StoresProvider";
const ExampleComponent: React.FC = () => {
const { UIStore } = useStores();
return (
@ChronSyn
ChronSyn / main.go
Created December 8, 2021 03:51 — forked from satishbabariya/main.go
supabase + gorush notification middleware service
package main
import (
"fmt"
"net/http"
"os"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/sirupsen/logrus"
@ChronSyn
ChronSyn / filter-data.sql
Last active March 14, 2022 23:38
Filtering JSONB data in Postgres
-- Postgres: How to find a matching element in a JSON array
--
-- Definitions:
-- - animal_size_in_mm: int = 50
-- - var_animal_type: string = "fish"
--
-- Data example:
--
-- [
-- { "animal_type": "fish", "name": "Bob", "animal_size": 48 },
@ChronSyn
ChronSyn / example.sh
Created July 24, 2022 02:48
Hasura - allow only select access to root queries
# SourceNameGoesHere = the name as it appears in Hasura dashboard
# See example: https://twitter.com/ChronSyn/status/1551035751512657921/photo/1
curl --location --request POST 'https://[your-hasura-address-dot-com]/v1/metadata' \
--header 'x-hasura-admin-secret: <your hasura admin secret>' \
--header 'X-Hasura-Role: admin' \
--header 'Content-Type: application/json' \
--data-raw '{
"type" : "pg_create_select_permission",
"args" : {