Skip to content

Instantly share code, notes, and snippets.

kyleshevlin / memoizedHandlers.js
Created Jan 22, 2021
Using React.useMemo to create a `handlers` object
View memoizedHandlers.js
// One of my new favorite React Hook patternms is to create handler
// functions for a custom hook using `React.useMemo` instead of
// `React.useCallback`, like so:
function useBool(initialState = false) {
const [state, setState] = React.useState(initialState)
// Instead of individual React.useCallbacks gathered into an object
// Let's memoize the whole object. Then, we can destructure the
// methods we need in our consuming component.
masyukun / recipeTools.js
Last active Jan 3, 2021
JavaScript functions to work with exported Cronometer recipes
View recipeTools.js
* Recipe Tools v0.1
* This version exists as a GitHub Gist at
* @license
* Copyright (c) 2020 Matthew Royal
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
// This is a proper alternative to
// The one in that file uses Promise, but that's *wrong*.
// We only used promise as a demo of its API. We'll remove it soon.
// As you can see below, the pure XMLHttpRequest code is just as clean,
// less mysterious for all, more performant, extensible, and actually correct.
// Ignore these externals for now. They're just for illustration
// purposes. I just copy pasted the Js code from
// by @noffle
autoinstall () {
local MODULES=$(cat $1 | grep "require('.*')" | sed "s/.*require('\(.*\)')/\1/" | grep -v '^\.' | tr '\n' ' ')
npm install $MODULES $@
adrianhall / AppSyncAPI.yaml
Last active Aug 13, 2022
A CloudFormation template for DynamoDB + Cognito User Pool + AppSync API for the Notes tutorial
View AppSyncAPI.yaml
Description: AWS AppSync Notes API
Type: String
Description: Name of the API - used to generate unique names for resources
MinLength: 3
MaxLength: 20
AllowedPattern: '^[a-zA-Z][a-zA-Z0-9_]*$'
dylanmckay / facebook-contact-info-summary.rb
Last active Jan 6, 2022
A Ruby script for collecting phone record statistics from a Facebook user data dump
View facebook-contact-info-summary.rb
#! /usr/bin/env ruby
# NOTE: Requires Ruby 2.1 or greater.
# This script can be used to parse and dump the information from
# the 'html/contact_info.htm' file in a Facebook user data ZIP download.
# It prints all cell phone call + SMS message + MMS records, plus a summary of each.
# It also dumps all of the records into CSV files inside a 'CSV' folder, that is created
scokmen / HttpStatusCode.ts
Created Apr 25, 2017
Typescript Http Status Codes Enum
View HttpStatusCode.ts
"use strict";
* Hypertext Transfer Protocol (HTTP) response status codes.
* @see {@link}
enum HttpStatusCode {
* The server has received the request headers and the client should proceed to send the request body
bahmutov /
Last active Mar 31, 2017
tmux basics


Install on Mac using brew install tmux and start with tmux

main commands

See help (list of commands) with Control-b ? key combination. Leave help view by pressing q key. From now on use Control-b (aka C-b) to start all tmux commands (C-b is called command prefix and can be changed, see tmux.config options).

getify / 1.js
Last active Oct 15, 2017
generators as object iterator
View 1.js
// ugly way
var obj = {
a: 1,
b: 2,
c: 3,
[Symbol.iterator]() {
var keys = Object.keys(this);
var idx = 0;
return {
haveaguess / HSBC.js
Created Oct 8, 2016 — forked from benjie/HSBC.js
HSBC Personal Statement to CSV
View HSBC.js
HSBC Personal Statement to CSV
Copyright: Benjie Gillam (2012)
License: WTFPL v2.0 ( )
Add the following bookmarklet to your browser: