Skip to content

Instantly share code, notes, and snippets.

@pkoppstein
pkoppstein / schema.jq
Last active April 30, 2024 07:39
schema.jq
module {
"name": "schema",
"description": "JSON Schema Inference",
"version": "0.0.3.1",
"homepage": "https://gist.github.com/pkoppstein/a5abb4ebef3b0f72a6ed",
"license": "MIT",
"author": "pkoppstein at gmail dot com"
};
# NEWS:
@alanzeino
alanzeino / lldb-debugging.md
Last active April 28, 2024 10:21
LLDB debugging with examples

LLDB Debugging Cheat Sheet

Commands

LLDB Commands

LLDB comes with a great set of commands for powerful debugging.

help

Your starting point for anything. Type help to get a list of all commands, plus any user installed ones. Type 'help for more information on a command. Type help to get help for a specific option in a command too.

@ragingwind
ragingwind / Backend Architectures Keywords and References.md
Last active April 17, 2024 10:51
Backend Architectures Keywords and References
@natecook1000
natecook1000 / curryRecipe.swift
Created November 9, 2014 03:37
Automatically write a function currying function with many arguments
// Curry Recipe
func curryRecipe(n: Int) -> String {
let types = join(", ", map(1...n, { "T\($0)" }))
let returnType = join(" -> ", map(1...n, { "T\($0)" }))
let closures = join(" in ", map(1...n, { "{ t\($0)" }))
let braces = join(" ", Array(count: n, repeatedValue: "}"))
return "func curry<\(types), R>(f: (\(types)) -> R) -> \(returnType) -> R {\r" +
" return \(closures) in f(\(types.lowercaseString)) \(braces)\r}"
}
@pyrtsa
pyrtsa / .prompt-time
Last active February 12, 2023 05:12
Make Bash report the start times all commands, and total durations of long-running ones.
export _ps1_timer
function _ps1_timer_start {
# echo START
_ps1_timer=${_ps1_timer:-`gdate +%s%N 2> /dev/null || date +%s%N`};
}
function _ps1_timer_stop {
# echo STOP
if [ -z "$_ps1_timer" ]; then
//
// NSObject+BlockObservation.h
// Version 1.0
//
// Andy Matuschak
// andy@andymatuschak.org
// Public domain because I love you. Let me know how you use it.
//
#import <Cocoa/Cocoa.h>
@pyrtsa
pyrtsa / .gitconfig
Created October 31, 2011 10:41
A few `git log` commands where things are nicely aligned
[alias]
l50 = "!f () { git log --abbrev-commit --date=short --pretty=format:'%h%x00%cd%x00%s%x00%an%x00%d' $@ | gawk -F '\\0' '{ printf \"\\033[31m%s\\033[0m \\033[32m%s\\033[0m %-50s \\033[30;1m%s\\033[0m\\033[33m%s\\n\", $1, $2, gensub(/(.{49}).{2,}/, \"\\\\1…\",\"g\",$3), $4, $5 }' | less -R; }; f"
l80 = "!f () { git log --abbrev-commit --date=short --pretty=format:'%h%x00%cd%x00%s%x00%an%x00%d' $@ | gawk -F '\\0' '{ printf \"\\033[31m%s\\033[0m \\033[32m%s\\033[0m %-80s \\033[30;1m%s\\033[0m\\033[33m%s\\n\", $1, $2, gensub(/(.{79}).{2,}/, \"\\\\1…\",\"g\",$3), $4, $5 }' | less -R; }; f"
lg50 = "!f () { git log --graph --color=always --abbrev-commit --date=relative --pretty=format:'%x00%h%x00%s%x00%cd%x00%an%x00%d' $@ | gawk -F '\\0' '{ printf \"%s\\033[31m%s\\033[0m %-50s \\033[32m%14s\\033[0m \\033[30;1m%s\\033[0m\\033[33m%s\\n\", $1, $2, gensub(/(.{49}).{2,}/, \"\\\\1…\",\"g\",$3), $4, $5, $6 }' | less -R; }; f"
lg80 = "!f () { git log --graph --color=always --abbrev-commit --date=re
@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell
@pyrtsa
pyrtsa / .ghci
Last active August 2, 2018 15:43
.ghci — Essential parts of my Haskell REPL config.
-- Show loaded modules in window title and use a green "λ>" as prompt.
-- Subsequent lines of multi-line commands shall begin with " |".
:set prompt "\SOH\ESC]0;GHCi: %s\BEL\ESC[32;1m\STXλ>\SOH\ESC[0m\STX "
:set prompt2 "\SOH\ESC[32;1m\STX |\SOH\ESC[0m\STX "
-- Paste and evaluate text from the OS X clipboard. (The pasted text also
-- prints in yellow unless pasting quietly using :paste-quiet.)
:set -package process
:def paste \_ -> do { paste <- System.Process.readProcess "pbpaste" [] ""; let cmd = if '\n' `elem` paste then ":{\ntype Ö = ()\n" ++ paste ++ "\n:}" else paste in putStrLn ("\SOH\ESC[33m\STX" ++ paste ++ "\SOH\ESC[0m\STX") >> return (":cmd return " ++ show cmd) }
:def paste-quiet \_ -> do { paste <- System.Process.readProcess "pbpaste" [] ""; let cmd = if '\n' `elem` paste then ":{\ntype Ö = ()\n" ++ paste ++ "\n:}" else paste in return (":cmd return " ++ show cmd) }
@pyrtsa
pyrtsa / Random.example.swift
Last active March 23, 2017 11:51
Sampling random numbers in Swift
import Random
random(0 ..< 10) // Int
random(1 ... 1000_000) // Int
random(-1000_000 ... 1000_000) // Int
random(Int.min ... Int.max) // Int
randomMax(UInt64.max) // UInt64
random(0 ... UInt64.max) // UInt64
random(1 ... UInt(10)) // UInt