Skip to content

Instantly share code, notes, and snippets.

View ryands17's full-sized avatar
:electron:
In love with TS & Rust

Ryan Dsouza ryands17

:electron:
In love with TS & Rust
View GitHub Profile
@danieljpgo
danieljpgo / useForm.ts
Created January 7, 2023 20:42
react-hook-form + zod
import {
useForm as useHookForm,
UseFormProps as useHookFormProps,
} from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { TypeOf, ZodSchema } from "zod";
interface UseFormProps<Z extends ZodSchema>
extends Exclude<useHookFormProps<TypeOf<Z>>, "resolver"> {
schema: Z;
@s0enke
s0enke / cdk_with_service_catalog.ts
Last active May 24, 2022 00:14
Generate AWS Service Catalog Products from CDK Constructs
// Possible since https://github.com/aws/aws-cdk/pull/17144
class VpcProduct extends servicecatalog.ProductStack {
vpc: aws_ec2.Vpc;
constructor(scope: Construct, id: string) {
super(scope, id);
this.vpc = new aws_ec2.Vpc(this, 'Vpc', {
@arpitbbhayani
arpitbbhayani / taxonomy.sql
Last active July 29, 2023 15:09
Quickly populate random 5 million + rows in a taxonomy using SQL
# create table topics!
create table topics (
id int primary key auto_increment,
name varchar(256),
parent_id int null,
type smallint not null,
foreign key (parent_id) references topics(id),
index(type)
);
@rauschma
rauschma / impatient-js-es2021.md
Last active August 31, 2023 07:02
ES2021 edition of “JavaScript for impatient programmers”

What is new in the ES2021 edition of “JavaScript for impatient programmers”?

Free to read online: exploringjs.com/impatient-js/

  • The exercises now run as native ESM modules on Node.js. Previously, they were run via the esm package.
  • Material on new ES2021 features:
    • String.prototype.replaceAll()
    • Promise.any()
    • Logical assignment operators
  • Underscores (_) as separators in number literals and bigint literals
@Integralist
Integralist / Examples.md
Last active February 7, 2024 22:56
[vim search and replace content using native vim cdo and cfdo commands] #vim #replace #macro #quickfix

There are two 'types' to be aware of with a quickfix window:

  1. entry: the actual line content (e.g. :grep foo will show a specific line that matched within a file).
  2. file: the actual file itself (e.g. the path to the file that contained the match).

To replace content using vim (via the quickfix window) you need to choose whether you want to apply the change via the quickfix 'entry' or via the 'file' as a whole.

If you use cdo, then your 'action' (i.e. how you're going to replace content) will be applied to every entry in the quickfix window.

If you use cfdo, then your action will be applied to each file in the quickfix window.

@tannerlinsley
tannerlinsley / createCrudHooks.js
Created November 29, 2020 06:39
A naive, but efficient starter to generate crud hooks for React Query
export default function createCrudHooks({
baseKey,
indexFn,
singleFn,
createFn,
updateFn,
deleteFn,
}) {
const useIndex = (config) => useQuery([baseKey], indexFn, config)
const useSingle = (id, config) =>
{
"Comment": "A Hello World example of the Amazon States Language using Pass states",
"StartAt": "Create pending order",
"States": {
"Create pending order": {
"Type": "Pass",
"Next": "Select Payment Method"
},
"Select Payment Method": {
"Type": "Choice",
@dabit3
dabit3 / combined-config.js
Created October 29, 2020 17:33
Combining CDK outputs with Amplify configuration
import Amplify from 'aws-amplify';
const { AppsyncCdkAppStack } = require('./outputs.json');
import config from './aws-exports';
Amplify.configure({
...config,
aws_appsync_graphqlEndpoint: AppsyncCdkAppStack.GraphQLAPIURL,
aws_appsync_apiKey: AppsyncCdkAppStack.GraphQLAPIKey
})
@dabit3
dabit3 / SingleTableAppSync.md
Last active February 24, 2023 20:05
GraphQL Single Table Design with DynamoDB and AWS AppSync

GraphQL

GraphQL Schema

type Customer {
  id: ID!
  email: String!
}
@JLarky
JLarky / README.md
Last active June 12, 2024 16:10
Ultimate example of react context hook with nice type-safe (TypeScript) wrappers and reduced boilerplate by using `ReturnType`