Skip to content

Instantly share code, notes, and snippets.

View alex-cory's full-sized avatar
🔥
🤔

Alex Cory alex-cory

🔥
🤔
View GitHub Profile
@pesterhazy
pesterhazy / indexeddb-problems.md
Last active November 16, 2024 13:33
The pain and anguish of using IndexedDB: problems, bugs and oddities

This gist lists challenges you run into when building offline-first applications based on IndexedDB, including open-source libraries like Firebase, pouchdb and AWS amplify (more).

Note that some of the following issues affect only Safari. Out of the major browsers, Chrome's IndexedDB implementation is the best.

Backing file on disk (WAL file) keeps growing (Safari)

When this bug occurs, every time you use the indexeddb, the WAL file grows. Garbage collection doesn't seem to be working, so after a while, you end up with gigabytes of data.

Random exceptions when working with a large number of indexeddb databases (Safari)

@alex-cory
alex-cory / mac-setup.sh
Last active January 4, 2023 14:53
My mac setup
#!/usr/bin/env bash
#
# BUGS:
# 1. not adding settings to .zshrc from below (i.e. default theme, packages, custom functions, etc.)
# 2. not auto-hiding doc
# 3. not auto-hiding menu bar
# 4. not adding .vimrc
# 5. not automatically copying iTerm profile, Option + Space not setup to toggle iTerm, doesn't default to opening iTerm at startup
#
# Bootstrap script for setting up a new OSX machine
@morajabi
morajabi / useRect.js
Created February 18, 2019 14:35
useRect — getBoundingClientRect() React Hook with resize handler
import { useLayoutEffect, useCallback, useState } from 'react'
export const useRect = (ref) => {
const [rect, setRect] = useState(getRect(ref ? ref.current : null))
const handleResize = useCallback(() => {
if (!ref.current) {
return
}
@egoens
egoens / ssh-add.md
Last active March 18, 2024 19:13
Use this if ssh key keeps asking for password
@Azerothian
Azerothian / jsobjtogql.js
Last active May 1, 2022 04:27
Convert JS Objects to GraphQL Queries
// Babel 2015 - ES6
// Convert a complex JS Object to GraphQL Query, should handle most use cases as of 21/01/2016
const o = {
query: {
fields: {
complex: {
aliasFor: "Products",
processArgs: {
coupon: (value) => {
return `"${JSON.stringify(value).replace(/"/g, "\\\"")}"`; // passing json string as a argument
@inexorabletash
inexorabletash / @ Indexed DB URLs via Service Workers.md
Last active December 20, 2023 01:29
Indexed DB URLs via Service Workers

URLs into Indexed DB, via Service Workers

Let's say you're using Indexed DB for the offline data store for a catalog. One of the object stores contains product images. Wouldn't it be great if you could just have something like this in your catalog page?

<img src="indexeddb/database/store/id">
@rafaeltuelho
rafaeltuelho / openid_access_token-decode.md
Last active June 12, 2023 23:45
Decoding an encoded oAuth JSON Web Token (JWT): access_token

Given an encoded (base64) JWT (access_token).

For example, see this sample OAuth2 response generated by JBoss APIMan/Keycloak

HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: application/json
Date: Tue, 25 Aug 2015 19:25:12 GMT
@revolunet
revolunet / python-es6-comparison.md
Last active November 2, 2024 12:22
# Python VS JavaScript ES6 syntax comparison

Python VS ES6 syntax comparison

Python syntax here : 2.7 - online REPL

Javascript ES6 via Babel transpilation - online REPL

Imports

import math
@EdwardBetts
EdwardBetts / pprint_color.py
Last active October 10, 2024 04:42
Python pprint with color syntax highlighting for the console
from pprint import pformat
from typing import Any
from pygments import highlight
from pygments.formatters import Terminal256Formatter
from pygments.lexers import PythonLexer
def pprint_color(obj: Any) -> None:
"""Pretty-print in color."""
@codeinthehole
codeinthehole / osx_bootstrap.sh
Last active May 19, 2024 20:47
Script to install stuff I want on a new OSX machine
#!/usr/bin/env bash
#
# Bootstrap script for setting up a new OSX machine
#
# This should be idempotent so it can be run multiple times.
#
# Some apps don't have a cask and so still need to be installed by hand. These
# include:
#
# - Twitter (app store)