Skip to content

Instantly share code, notes, and snippets.

@huytd
huytd / wordle.md
Last active May 16, 2024 20:39
Wordle in less than 50 lines of Bash

image

How to use:

./wordle.sh

Or try the unlimit mode:

@jmatsushita
jmatsushita / README
Last active May 13, 2024 18:21
Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
###
### [2023-06-19] UPDATE: Just tried to use my instructions again on a fresh install and it failed in a number of places.
###. Not sure if I'll update this gist (though I realise it seems to still have some traffic), but here's a list of
###. things to watch out for:
### - Check out the `nix-darwin` instructions, as they have changed.
### - There's a home manager gotcha https://github.com/nix-community/home-manager/issues/4026
###
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs).
# So here's a minimal Gist which worked for me as an install on a new M1 Pro.
@ole
ole / let.swift
Created September 9, 2019 15:14
A replacement for let bindings in Swift function builders
import SwiftUI
func `let`<Value, Return>(_ expression: Value, body: (Value) -> Return) -> Return {
body(expression)
}
struct ContentView: View {
var body: some View {
GeometryReader { geometry in
`let`(geometry.size.width / 2) { lineWidth in
@ravron
ravron / README.md
Last active March 18, 2024 18:16
Options to prevent accidental Yubikey OTP triggering

Tired of spamming Yubikey one-time password (OTP) codes into Slack? Here are two options to help prevent that. You can do either or both. Both require ykman, the Yubikey CLI configuration manager. Get it with Homebrew:

brew install ykman

If you…

@ldez
ldez / gmail-github-filters.md
Last active May 16, 2024 11:07
Gmail and GitHub - Filters

Gmail and GitHub

How to filter emails from GitHub in Gmail and flag them with labels.

The labels in this document are just examples.

Pull Request

Filter Label
@tubaman
tubaman / ledgerparser.py
Last active February 27, 2023 16:03
ledgerparser
"""ledger journal parser
We use this to parse the ledger file because we want to preserve the
exact format of the file including spaces, etc. It maps the parsed
transaction to the origin lines of the file.
"""
import ledger
@bishboria
bishboria / springer-free-maths-books.md
Last active April 25, 2024 06:27
Springer made a bunch of books available for free, these were the direct links
@endash
endash / gist:acda517225dc9f4bc9db
Last active September 27, 2019 06:10
Photoshop style gradients in Core Graphics via use of CGShader (with thanks to @jernejstrasner, see his explanation of why your gradients might not look how your designers intended http://jernejstrasner.com/2014/01/09/smooth-gradients-ios.html) ⚠️ see comments for notes
func SineEaseInOutLinearAverage(x: Double) -> Double {
var easeInOutSine = ((cos(M_PI * x) - 1) / -2)
return (easeInOutSine + x) / 2
}
func ShadingFunctionCreate(startColor: NSColor, _ endColor: NSColor, _ slopeFunction: (Double) -> Double) -> (UnsafePointer<CGFloat>, UnsafeMutablePointer<CGFloat>) -> Void {
return { inData, outData in
let q = CGFloat(slopeFunction(Double(inData[0])))
outData[0] = startColor.redComponent + (endColor.redComponent - startColor.redComponent) * q
outData[1] = startColor.greenComponent + (endColor.greenComponent - startColor.greenComponent) * q
@jonathan-beebe
jonathan-beebe / clean_old_code_simulators.sh
Last active February 12, 2019 19:40
Clean out unused Xcode Simulators
# Close Xcode & the iOS Simulator
# http://stackoverflow.com/a/30940055
# Remove any old runtimes from this directory.
cd /Library/Developer/CoreSimulator/Profiles/Runtimes
# e.g.
sudo rm -rf iOS\ 8.1.simruntime
# http://stackoverflow.com/a/11790983
# Remove the download receipts for simulators you don't need anymore.