Skip to content

Instantly share code, notes, and snippets.

@johnoscott
johnoscott / vscode-macos-context-menu.md
Created March 3, 2023 22:02 — forked from idleberg/vscode-macos-context-menu.md
“Open in Visual Studio Code” in macOS context-menu

Open in Visual Studio Code

  • Open Automator
  • Create a new document
  • Select Quick Action
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
    • your default shell should already be selected, otherwise use /bin/zsh for macOS 10.15 (”Catalina”) or later
    • older versions of macOS use /bin/bash
  • if you're using something else, you probably know what to do 😉
@johnoscott
johnoscott / docker-compose.yaml
Last active April 14, 2022 01:19 — forked from jdaarevalo/docker-compose.yaml
docker_compose_postgres
# https://hub.docker.com/_/postgres
# Usage:
# $ docker compose up
# NOTE: version not required as of compose spec v
# version: '3.7'
# docker run --name basic-postgres --rm \
# -e POSTGRES_USER=postgres \

Getting Started With Plug'n'Play

If you use create-react-app, #5136 (released with the 2.0) implements a --use-pnp option that allows you to easily create a new project using PnP! In this case, just use create-react-app --use-pnp together with Yarn 1.12, and you're good to go! 👍

Plug'n'Play is a new initiative from Yarn that aims to remove the need for node_modules. It's already available, and has proved being effective even on large-scale infrastructures. This document describes in a few steps how to quickly get started with it. Spoiler alert: it's quite easy 🙂

First, download a package manager that supports it. Yarn 1.12 already does, so that's what we're going to use! To install it, just follow the instructions on our website: https://yarnpkg.com/en/docs/install

If everything is ok, running yarn --version should give you v1.12.1 or higher. If you don't get this result maybe a

@johnoscott
johnoscott / ngrok-installation.md
Created August 5, 2021 01:48 — forked from wosephjeber/ngrok-installation.md
Installing ngrok on Mac

Installing ngrok on OSX

For Homebrew v2.6.x and below:

brew cask install ngrok

For Homebrew v2.7.x and above:

@johnoscott
johnoscott / babel_url_encoding.md
Last active August 2, 2021 22:37
babel url encoding for http get params
@johnoscott
johnoscott / macro.gs
Created July 12, 2021 19:23 — forked from jsjoeio/macro.gs
Google Spreadsheet macro example
/** @OnlyCurrentDoc */
const startDate = new Date("2021-06-16")
// so the first one is D2:K2
function MarkEmptyCellsInYesterdayRowWithHyphen() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Group 2 - B");
// Activates the sheet
SpreadsheetApp.setActiveSheet(sheet);
const today = new Date()
@johnoscott
johnoscott / esm-package.md
Created June 8, 2021 03:23 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@johnoscott
johnoscott / cognito.py
Created December 14, 2020 14:12 — forked from bjinwright/cognito.py
Example of how to make an authorized call to API Gateway using Boto3, Requests, and AWS4Auth. http://stackoverflow.com/questions/37336286/how-do-i-call-an-api-gateway-with-cognito-credentials-in-python
import boto3
import datetime
import json
from requests_aws4auth import AWS4Auth
import requests
boto3.setup_default_session(region_name='us-east-1')
identity = boto3.client('cognito-identity', region_name='us-east-1')
account_id='XXXXXXXXXXXXXXX'
## Connect PG8000 to database
conn = pg8000.connect(database=args['db_name'],user=args['db_user'],password=args['db_password'],host=args['db_host'],port=5432)
cur = conn.cursor()
# ...
# Example upsert query
cur.execute("INSERT INTO {} SELECT * FROM {} ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name".format('campaigns', 'tmp_staging_campaings'))
# ...
conn.commit()
cur.close()
conn.close()
@johnoscott
johnoscott / sample-excw.excalidraw
Last active July 13, 2020 16:15
Draw.io Diagrams
{
"type": "excalidraw",
"version": 2,
"source": "https://excalidraw.com",
"elements": [
{
"type": "rectangle",
"version": 192,
"versionNonce": 1899200910,
"isDeleted": false,