Skip to content

Instantly share code, notes, and snippets.

View johncmunson's full-sized avatar

John Munson johncmunson

View GitHub Profile
@johncmunson
johncmunson / Setting Up a Python Development Environment for macOS.md
Last active November 29, 2023 20:09
Setting Up a Python Development Environment for macOS
View Setting Up a Python Development Environment for macOS.md

Setting Up a Python Development Environment for macOS

Setting up a development environment for Python can be a bit confusing, mainly stemming from the fact that there are multiple competing standards for package management.

Compared with Node.js, which indeed has several different popular package managers such as npm, yarn, and pnpm, they all agree on a common manifest format (package.json) and they are largely interoperable with each other. In addition, it's very clear to new developers that npm is where you ought to start.

This is not the case with Python, where there are multiple competing manifest formats (requirements.txt, Pipfile, pyproject.toml), interoperability is hit and miss, and it's not clear where to start because the official PEPs are somewhat conflicting and the Python Packaging Authority (PyPA) doesn't take a strong stance on the issue either.

  • pip, which uses requirements.txt, is the most official and is in the standard lib. But, it's lacking in features you might
@johncmunson
johncmunson / accumulatedDebounce.js
Created July 28, 2020 17:57
Debounce a function, with the option to accumulate args
View accumulatedDebounce.js
export function debounce(delay, callback, accumulateData) {
let timeout = null
let data = []
return function () {
if (accumulateData) {
const arr = []
for (let i = 0; i < arguments.length; ++i) {
arr.push(arguments[i])
}
data.push(arr)
View asyncRetry.js
const getRandomBool = () => Math.random() >= 0.5
const getJitterMultiplier = (min: number, max: number): number => {
const percent = (Math.random() * (max - min) + min) / 100
return getRandomBool() ? 1 + percent : 1 - percent
}
const asyncRetry = async (fn, opts = {}) => {
const defaultOpts = { retries: 5, interval: 100, exponential: false, jitter: false }
opts = { ...defaultOpts, ...opts }
View 2020-07-28.zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/epzio/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
View elm-language-client-vscode-error-output.txt
[Info - 2:32:46 PM] Loading Elm tree-sitter syntax from ../.vscode/extensions/elmtooling.elm-ls-vscode-0.10.2/server/out/tree-sitter-elm.wasm
[Info - 2:32:47 PM] Found 1 elm.json files for workspace /Users/epzio/PhotoGroove
[Info - 2:32:47 PM] Found 1 unique elmWorkspaces for workspace /Users/epzio/PhotoGroove
[Info - 2:32:47 PM] Starting language server for folder: file:///Users/epzio/PhotoGroove
[Info - 2:32:47 PM] Elm version 0.19.1 detected.
[Info - 2:32:47 PM] Reading elm.json from /Users/epzio/PhotoGroove/elm.json
[Info - 2:32:47 PM] 2 source-dirs and test folders found
[Info - 2:32:47 PM] Found 35 files to add to the project
[Info - 2:32:47 PM] Adding /Users/epzio/PhotoGroove/src/PhotoGroove.elm
[Info - 2:32:47 PM] Adding /Users/epzio/.elm/0.19.1/packages/elm/browser/1.0.2/src/Browser.elm
View prepare-commit-msg.sh
#!/bin/bash
#
# Inspects branch name and checks if it contains a Jira ticket number (i.e. ABC-123).
# If yes, commit message will be automatically prepended with [ABC-123].
#
# Useful for looking through git history and relating a commit or group of commits
# back to a user story.
#
@johncmunson
johncmunson / promise-concurrency.js
Created September 27, 2019 16:09
Throttling concurrent API calls
View promise-concurrency.js
const pMap = require('p-map')
const Chance = require('chance')
const chance = new Chance()
const userIds = [ 52, 84, 71, 66, 12, 39, 18, 99, 7, 48 ]
// Simulate a network call
const getUser = async (id) => {
await new Promise(resolve => setTimeout(resolve, 1000))
@johncmunson
johncmunson / app.js
Created February 8, 2018 07:28 — forked from hagino3000/app.js
JSON-RPC for node (express)
View app.js
/**
* Module dependencies.
*/
var express = require('express');
var rpcMethods = require('./methods.js');
var app = module.exports = express.createServer();
// Configuration
View ternarySwitchAssignment.js
// Sometimes we do cool stuff like this...
let tacoType = hasQueso ? 'supreme' : 'normal'
// Or this in our markup...
`ng-class="isActive && 'md-primary'"`
// Or this to set default values...
this.color = config.color || 'blue'
// Sometimes though we'd like to have more
@johncmunson
johncmunson / import-export-snippets.cson
Created February 16, 2017 09:11
Import/Export snippets
View import-export-snippets.cson
'default import':
'prefix': 'impDefault'
'body': 'import ${1:defaultMember} from \'${2:module-name}\''
'named import':
'prefix': 'impNamed'
'body': 'import { ${1:namedMember} } from \'${2:module-name}\''
'export default':
'prefix': 'expDefault'
'body': 'export default ${1:name}'
'export':