Skip to content

Instantly share code, notes, and snippets.

View joshbeckman's full-sized avatar
👍

Josh Beckman joshbeckman

👍
View GitHub Profile
@jthodge
jthodge / universal-switcher
Created September 6, 2020 22:07
Show macOS app switcher across all monitors
defaults write com.apple.Dock appswitcher-all-displays -bool true
killall Dock
@hriddhidey
hriddhidey / fetch.go
Last active October 3, 2021 16:52
Fetch makes network calls using the method (POST/GET..), the URL // to hit, headers to add (if any), and the body of the request. This function can serve as a singular resource for all your network calls to pass through, thus becoming an http interceptor. You may add a lot of n/w layer related customizations here as you wish - headers, auth, red…
// Fetch makes network calls using the method (POST/GET..), the URL // to hit, headers to add (if any), and the body of the request.
// Feel free to add more stuff to before/after making the actual n/w call!
func Fetch(method string, url string, header map[string]string, body io.Reader) (*http.Response, err) {
// Create client with required custom parameters.
// Options: Disable keep-alives, 30sec n/w call timeout.
client := &http.Client{
Transport: &http.Transport{
DisableKeepAlives: true,
},
Timeout: time.Duration(10 * time.Second),
@enricofoltran
enricofoltran / main.go
Last active April 1, 2024 00:17
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@stuboo
stuboo / python_narro.py
Last active March 16, 2017 17:20 — forked from anonymous/python_narro.py
Interacting with the Narro.co API with Python
"""
Interacting with the Narro.co API with Python
### Implementation
1. ask narro for authorization_code
2. visit the url to grant permission
3. paste the authorization_code into the script
4. exchange the authorization_code + secret_key for an access token
5. use the access token
@cyphunk
cyphunk / softmax.js
Last active April 6, 2024 11:21 — forked from vladimir-ivanov/softmax.js
softmax function implementation in js
// Fork & examples for the one-line version by @vladimir-ivanov:
//let softmax = (arr) => (index) => Math.exp(arr[index]) / arr.map(y => Math.exp(y)).reduce((a, b) => a + b);
//
// Also see comments for improvements
function softmax(arr) {
return arr.map(function(value,index) {
return Math.exp(value) / arr.map( function(y /*value*/){ return Math.exp(y) } ).reduce( function(a,b){ return a+b })
})
}
@joepie91
joepie91 / blockchain.md
Last active June 25, 2023 08:40
Is my blockchain a blockchain?

Your blockchain must have all of the following properties:

  • It's a merkle tree, or a construct with equivalent properties.
  • There is no single point of trust or authority; nodes are operated by different parties.
  • Multiple 'forks' of the blockchain may exist - that is, nodes may disagree on what the full sequence of blocks looks like.
  • In the case of such a fork, there must exist a deterministic consensus algorithm of some sort to decide what the "real" blockchain looks like (ie. which fork is "correct").
  • The consensus algorithm must be executable with only the information contained in the blockchain (or its forks), and no external input (eg. no decisionmaking from a centralized 'trust node').

If your blockchain is missing any of the above properties, it is not a blockchain, it is just a ledger.

@jesstelford
jesstelford / README.md
Last active November 14, 2023 12:26
Starving the Event Loop with Microtasks

Starving the Event Loop with microtasks

"What's the Event Loop?"

Sparked from this twitter conversation when talking about doing fast async rendering of declarative UIs in Preact

These examples show how it's possible to starve the main event loop with microtasks (because the microtask queue is emptied at the end of every item in the event loop queue). Note that these are contrived examples, but can be reflective of situations where Promises are incorrectly expected to yield to the event loop "because they're async".

  • setTimeout-only.js is there to form a baseline
@corykeane
corykeane / manifest_shipments.py
Created January 20, 2016 20:30
Python manifester for EasyPost shipments
import easypost
import argparse
import time
def manifest(tracking_codes):
print("Manifesting: %s" % ", ".join(tracking_codes))
shipments = [easypost.Shipment.retrieve(tracking_code)
for tracking_code in tracking_codes]
batch = easypost.Batch.create(shipments=shipments)
@Avaq
Avaq / combinators.js
Last active May 1, 2024 09:38
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
@nibrahim
nibrahim / accounts-budget.dat
Last active February 25, 2016 17:53
Ledger sample input with budget
;-*-ledger-*-
~ Monthly
Expenses:Rent 5000 Rs
Expenses:Groceries 3500 Rs
Expenses:Domestic 4000 Rs
Expenses:Electricity 1500 Rs
Expenses:Entertainment 2000 Rs
Expenses:Food 1000 Rs
Expenses:Fitness 500 Rs
Expenses:Hosting 2500 Rs