Skip to content

Instantly share code, notes, and snippets.

Avatar

Kyle KTruong008

View GitHub Profile
@snuffyDev
snuffyDev / hooks.ts
Created Feb 4, 2022
Reddit OAuth2 (outdated) SvelteKit Hooks file
View hooks.ts
import type { Handle, GetSession } from '@sveltejs/kit';
import * as cookie from 'cookie';
import * as jsonwebtoken from 'jsonwebtoken';
import { handleTokenRefresh } from '$lib/helpers/refresh';
import { JWT_SECRET } from './env';
const getJWT = (cookie: string): jsonwebtoken.Jwt => {
if (typeof cookie !== 'string' || cookie.length === 0) return;
return jsonwebtoken.decode(cookie, { complete: true });
@pesterhazy
pesterhazy / indexeddb-problems.md
Last active Aug 23, 2022
The pain and anguish of using IndexedDB: problems, bugs and oddities
View indexeddb-problems.md

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)

@NigelEarle
NigelEarle / Knex-Migrations-Seeding.md
Last active Oct 5, 2022
Migration and seeding instructions using Knex.js!
View Knex-Migrations-Seeding.md

Migrations & Seeding

What are migrations??

Migrations are a way to make database changes or updates, like creating or dropping tables, as well as updating a table with new columns with constraints via generated scripts. We can build these scripts via the command line using knex command line tool.

To learn more about migrations, check out this article on the different types of database migrations!

Creating/Dropping Tables

View promise_series.js
let itemIDs = [1, 2, 3, 4, 5];
itemIDs.reduce((promise, itemID) => {
return promise.then(_ => api.deleteItem(itemID));
}, Promise.resolve());
@kitten
kitten / reactiveconf-sc-cfp.md
Last active Nov 17, 2020
ReactiveConf 2017 Lightning Talk CFP: With styled-components into the future
View reactiveconf-sc-cfp.md

styled-components Logo

With styled-components into the future

Preprocessing is dead, long live preprocessing!


This is a CFP for ReactiveConf 2017's open call for Lightning talks. If you'd like to see this talk become a reality, please star this gist. #ReactiveConf

@stewartknapman
stewartknapman / shopify-money.js
Created Feb 27, 2017
The Shopify.formatMoney method extracted from option_selection.js for stand-alone purposes.
View shopify-money.js
var Shopify = Shopify || {};
// ---------------------------------------------------------------------------
// Money format handler
// ---------------------------------------------------------------------------
Shopify.money_format = "${{amount}}";
Shopify.formatMoney = function(cents, format) {
if (typeof cents == 'string') { cents = cents.replace('.',''); }
var value = '';
var placeholderRegex = /\{\{\s*(\w+)\s*\}\}/;
var formatString = (format || this.money_format);
@thegitfather
thegitfather / vanilla-js-cheatsheet.md
Last active Oct 5, 2022
Vanilla JavaScript Quick Reference / Cheatsheet
View vanilla-js-cheatsheet.md
View Nginx_Cheat_Sheet.md
@LeCoupa
LeCoupa / bash-cheatsheet.sh
Last active Sep 29, 2022
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
View bash-cheatsheet.sh
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@staltz
staltz / introrx.md
Last active Oct 5, 2022
The introduction to Reactive Programming you've been missing
View introrx.md