Skip to content

Instantly share code, notes, and snippets.

View kelleyvanevert's full-sized avatar
🦕
would like a pet dino

Kelley van Evert kelleyvanevert

🦕
would like a pet dino
View GitHub Profile
@kelleyvanevert
kelleyvanevert / MinScoreSlider.tsx
Created November 10, 2022 10:18
React Native Reanimated
import React from "react";
import { View, StyleSheet, Dimensions } from "react-native";
import { darken } from "polished";
import Animated, {
useAnimatedStyle,
Extrapolate,
useSharedValue,
useAnimatedProps,
interpolate,
useAnimatedGestureHandler,
@kelleyvanevert
kelleyvanevert / README.md
Created May 22, 2021 10:43
Custom implementation of useQueryParams

This is a custom implementation of use-query-params, which has served me quite well for about two years, but was getting more and more comprehensive w/ features & a level of abstraction I didn't really need, while also somehow messing up my build process. (The latter is mostly my own fault though, due to my setup w/ SSR, react-ssr-prepass, and trying to keep most of the server code within the webpack output instead of using a generous nodeExternals setting because of the way our CD setup works currently.. But, nonetheless, use-query-params seemed to be a hassle, haha.)

  • No duplicate query params, just a single one. If you want an array, use e.g. StringArrayParam
  • No null vs undefined, or "existent w/o value" vs "inexistent", difference. The query param is either there, or isn't there, and what value is takes depends on the type config.
@kelleyvanevert
kelleyvanevert / example-query.sql
Last active March 11, 2024 18:11
TypeScript-typed generateQuery for creating single-SQL nested queries for a certain schema
select json_build_object('__table', 'user', 'firstName', e."first_name", 'lastName', e."last_name", 'managedResources', coalesce("t_managedResources"."data", '[]'), 'ratings', coalesce("t_ratings"."data", '[]')) as "data"
from "user" as "e"
left join (
select "manager_id" as "fkey", json_agg(json_build_object('__table', 'resource', 'ratingTotals', "t_ratingTotals"."data")) as "data"
from "resource" as "e"
left join (
select "resource_id" as "fkey", json_build_object('__table', 'rating_totals', 'avgSatisfaction', e."avg_satisfaction") as "data"
from "rating_totals" as "e"
) as "t_ratingTotals" on "t_ratingTotals"."fkey" = "e"."id"
group by "manager_id"
@kelleyvanevert
kelleyvanevert / README.md
Last active May 24, 2023 12:19
A little helper script that uses Babel to scan your React source code for untranslated content

A little helper script that uses Babel to scan your React source code for untranslated content

This script will analyze the translation coverage in your source code. It improves upon i18next-scanner here and there, and is custom-tailored to a use-case I have.

The key insight here is that parsing and scanning code with Babel is remarkably simple, and you can just build a small tool with it when the need arises. And there's a good chance this is an easier path than trying to get existing tooling to work for you!

It assumes you wrap all your content strings like such:

@kelleyvanevert
kelleyvanevert / JSIdentifier.js
Last active June 7, 2019 23:48
Parsing Literal JSX to an AST with line/col/offset info with Nearley + moo
// See [https://mathiasbynens.be/notes/javascript-identifiers-es6]
module.exports = /(?!(?:do|if|in|for|let|new|try|var|case|else|enum|eval|null|this|true|void|with|await|break|catch|class|const|false|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$)(?:[$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09D
@kelleyvanevert
kelleyvanevert / JSON.ne
Created June 6, 2019 17:25
Parsing JSON to an AST with line/col/offset info with Nearley + moo
# Initially based on [https://github.com/kach/nearley/blob/master/examples/json.ne],
# and then reworked to resemble JSON parse from [https://astexplorer.net/]
# JSON [http://www.json.org/]
# Tested with nearleyc v2.16.0
# interface Pos {
# line: number;
# column: number;
@kelleyvanevert
kelleyvanevert / README.md
Last active December 5, 2018 13:51
Analytics via GTM instead of directly to Google Analytics

Migrating to GTM

Overview of changes

Previous setup

1) Manual GTM registration

As below, but I believe it was chosen not to use, or abandoned or something, because the current GTM configuration does not seem to have any active triggers used.

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDEfLUZC/zmWtmxtkvBNERmlHnPi9iNLzgxqscsHOvUQH9OP+HiPrjIkPDeT5+641D3dc/8elnggynjFvWGd//kZmpOqrRPqQgXlTSSVuCZXMe3wT0stZVEFGcwTf7o1+zhzLC+WwgQQUt4BS/2yMqwiPqAg/4BegNhuOO7xk88dk037/Z+vHbyr8shol3e2GgVK8dtujQPbqqM3dk/ecL5Oo2NlWgCS2fqRKIALBZJYnRrpfvirObF6A/mODNgEvWItFx2kDe9Bj4iWdDDqHE/b3Nuzsz7VG98xXgconW7gFAV/XH6NBKG3Ul/R/Ptq94jIjSBLcJR0Ubc4gpvFz4r
{"0":{"independent":[[[285,104],[280,106],[273,115],[271,119],[266,125],[260,135],[258,141],[257,148],[255,156],[251,171],[250,177],[250,184],[250,189],[250,195],[252,202],[255,208],[259,213],[263,218],[268,223],[272,227],[277,229],[282,231],[290,231],[295,230],[299,228],[305,223],[309,216],[312,205],[314,200],[314,194],[317,180],[318,172],[319,166],[320,153],[319,143],[317,134],[315,127],[314,123],[312,116],[310,110],[305,107],[301,105],[293,103],[287,104]]]},"1":{"independent":[[[254,130],[263,129],[269,127],[274,126],[277,123],[279,120],[280,128],[281,134],[279,158],[278,167],[278,176],[277,189],[278,195],[278,202],[278,212],[278,217],[278,225],[277,230],[277,234],[262,235],[255,235],[249,235],[244,236],[251,236],[268,237],[281,238],[294,239],[303,239],[310,240],[320,240],[328,240],[333,241]]]},"2":{"independent":[[[261,150],[263,144],[265,140],[275,129],[280,123],[289,115],[295,112],[302,112],[307,114],[312,117],[317,122],[320,125],[321,129],[325,138],[324,143],[323,148],[322,160],[321,166],[320,173],[317
@kelleyvanevert
kelleyvanevert / whatsapp-counting-autoresponder.js
Last active May 3, 2018 16:41
A little chunk of code to cheat in a counting Whatsapp group
// config
var only_respond = true; // if false, responds to own messages as well
// state
var lastno = 34350; // the last known posted number
var mine = true; // was this last number my own post?
// The complication here, is that