Skip to content

Instantly share code, notes, and snippets.

View streamich's full-sized avatar
🕶️
married

Va Da streamich

🕶️
married
  • Switzerland
  • 17:50 (UTC +02:00)
View GitHub Profile
import { useState, useEffect } from "react";
export type AsyncState<T> =
| { loading: false; error?: undefined; value?: undefined }
| { loading: true; error?: undefined; value?: undefined }
| { loading: false; error: Error; value?: undefined }
| { loading: false; error?: undefined; value: T };
export type AsyncUtils<C extends {}, A extends any[]> = {
setArgs: (args: A | undefined) => void;
const React = require("react");
const Lifecycles = React.createLifecycleEvents({
didMount({ setState }) {
setState({
disabled: false,
});
},
didUpdate({ inputRef }) {
if (document.activeElement !== inputRef.value) {
@gabeweaver
gabeweaver / react-cognito-auth-js.js
Last active January 20, 2024 15:03
React + Cognito User Pools + Cognito Identity JS Example
/*
This example was built using standard create-react-app out of the box with no modifications or ejections
to the underlying scripts.
In this example, i'm using Google as a social provider configured within the Cognito User Pool.
Each step also represents a file, so you can see how I've chosen to organize stuff...you can do it however
you'd like so long as you follow the basic flow (which may or may not be the official way....but its what I found that works.
The docs are pretty horrible)
@jkrems
jkrems / es-module-history.md
Last active November 5, 2023 19:35
History of ES modules

Modules - History & Future

History

@rgl
rgl / wait_for_http_200.sh
Last active March 7, 2024 17:08
Wait for an HTTP endpoint to return 200 OK with Bash and curl
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9000)" != "200" ]]; do sleep 5; done'
# also check https://gist.github.com/rgl/c2ba64b7e2a5a04d1eb65983995dce76
@tomysmile
tomysmile / mac-setup-redis.md
Last active March 18, 2024 22:12
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@bellbind
bellbind / hello-asm.c
Last active August 22, 2018 23:04
[clang][gcc][c][osx] inline asm to syscall on OSX amd64
/* clang hello-asm.c -o hello-asm */
int main() {
long write = 0x2000004; /* syscall "write" on MacOS X */
long stdout = 1;
char * str = "Hello World\n";
unsigned long len = 12;
unsigned long ret = 0;
/* ret = write(stdout, str, len); */
__asm__("movq %1, %%rax;\n"
"movq %2, %%rdi;\n"
@ngpestelos
ngpestelos / remove-docker-containers.md
Last active March 5, 2024 20:45
How to remove unused Docker containers and images

May 8, 2018

I wrote this four years ago, so instead use this command:

$ docker rmi $(docker images -q -f dangling=true)
@kingbin
kingbin / gist:9435292
Last active May 4, 2024 12:17
Manually Start/Stop PostgresSQL on Mac
# Stop PostgreSQL from auto starting
sudo launchctl unload -w /Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist
# Enable PostgreSQL to auto start
sudo launchctl load -w /Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist
# Start postgres
$ sudo su postgres
Password:
bash-3.2$ pg_ctl -D /Library/PostgreSQL/9.3/data/ start