Skip to content

Instantly share code, notes, and snippets.

View demsey2's full-sized avatar

Dawid Tomkalski demsey2

  • Gold Coast
View GitHub Profile
@mmazzarolo
mmazzarolo / country-codes.ts
Created May 6, 2023 12:09
WIP - Type-safe TypeScript ISO 3166 country codes (names, two-letters codes, and three-letters codes)
// ==========================================
// (WIP) TYPE-SAFE ISO 3166 COUNTRY CODES
// ==========================================
/**
* Countries data.
* This is the source that should be updated if you want to add/remove new country codes.
*/
const countriesData = [
["Afghanistan", "AF", "AFG"],
@DavidWells
DavidWells / javascript-proxy-as-rest-client.js
Last active May 12, 2024 14:24
Using a javascript proxy as low code REST client
/* Using a JavaScript proxy for a super low code REST client */
// via https://dev.to/dipsaus9/javascript-lets-create-aproxy-19hg
// also see https://towardsdatascience.com/why-to-use-javascript-proxy-5cdc69d943e3
// also see https://github.com/fastify/manifetch
// also see https://github.com/flash-oss/allserver
// and https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const createApi = (url) => {
return new Proxy({}, {
get(target, key) {
@axelabs
axelabs / expAws.sh
Last active July 28, 2023 00:45
Export selected AWS profile into environments 🐚
# Usage from POSIX shell: . ./expAws.sh
PROFILES=$(awk configure list-profiles)
select PROFILE in $PROFILES; do
export AWS_ACCESS_KEY_ID="$(aws configure get aws_access_key_id --profile $PROFILE)"
export AWS_SECRET_ACCESS_KEY="$(aws configure get aws_secret_access_key --profile $PROFILE)"
export AWS_DEFAULT_REGION="$(aws configure get region --profile $PROFILE)"
export AWS_SESSION_TOKEN="$(aws configure get aws_session_token --profile $PROFILE)"
export AWS_SECURITY_TOKEN="$(aws configure get aws_security_token --profile $PROFILE)"
@kennovation1
kennovation1 / busmon.py
Last active August 23, 2021 16:07
Continuously monitor and pretty print Amazon EventBridge traffic as captured in CloudWatch Logs
# busmon.py
# Monitor CloudWatch Logs for EventBridge traffic.
#
# This script assumes that there is a Lambda function snooping an EventBridge bus
# and logging the events to a CloudWatch Logs group.
#
# Your format will likely be different and will require slight adjustments to the parsing
# logic below. The default format assumed for this version is:
# timestamp and other stuff|field|field|field|SNOOPED detail-type: <eventName> jsonString
# That is 5 pipe-delimited fields, where the last field is the only field used.
@bodokaiser
bodokaiser / context.ts
Last active August 10, 2023 01:00
React Hook integration for AWS Amplify Auth
import React from "react"
import { CognitoUser } from "@aws-amplify/auth"
import { useAuth } from "./hooks"
import { SignInInput } from "./types"
interface AuthState {
user: CognitoUser | null
signIn(input : SignInInput): Promise<void>
signOut(): Promise<void>
@reggi
reggi / question-nestjs-graphql-nested-resolvers.md
Last active July 10, 2023 14:11
How do I have nested resolvers in nestjs / type-graphql?

I am trying to find a way that a resolver can essentially return another resolver using [nest.js][1] for creating [Resolvers][2], and [type-graphql][3] to create [object types][4].

Here's an example with the star-wars graphql api

{
  allVehicles(first: 1, last: 100) {
    vehicles {
      name
@martinheld
martinheld / GraphQL introspection query via curl.md
Last active April 16, 2024 16:26
GraphQL introspection query via curl

GraphQL introspection query via curl

cat introspection_query.json

{ 
  "query": "query IntrospectionQuery {
      __schema {
        queryType { name }
        mutationType { name }
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active June 2, 2024 11:24
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
/** Used by Flavor to mark a type in a readable way. */
export interface Flavoring<FlavorT> {
_type?: FlavorT;
}
/** Create a "flavored" version of a type. TypeScript will disallow mixing flavors, but will allow unflavored values of that type to be passed in where a flavored version is expected. This is a less restrictive form of branding. */
export type Flavor<T, FlavorT> = T & Flavoring<FlavorT>;
/** Used by Brand to mark a type in a readable way. */
export interface Branding<BrandT> {
_type: BrandT;
@jeroen-meijer
jeroen-meijer / flutterrepair.sh
Last active August 23, 2023 04:05
Flutter Repair iOS - When your Flutter build comes up with weird Xcode errors, run this script from your Flutter project directory and it will clean out all the old iOS stuff and get your project dependencies fresh.
#!/bin/sh
# To run, download the script or copy the code to a '.sh' file (for example 'flutterrepair.sh') and run like any other script:
# sh ./flutterrepair.sh
# or
# sudo sh flutterrepair.sh
echo "Flutter Repair (by jeroen-meijer on GitHubGist)"
echo Cleaning project...