Skip to content

Instantly share code, notes, and snippets.

View richardhenry's full-sized avatar

Richard Henry richardhenry

  • San Francisco, CA
View GitHub Profile
@kjmph
kjmph / A_UUID_v7_for_Postgres.sql
Last active November 21, 2025 06:07
Postgres PL/pgSQL function for UUID v7 and a bonus custom UUID v8 to support microsecond precision as well. Read more here: https://datatracker.ietf.org/doc/rfc9562/
-- Based off IETF draft, https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
create or replace function uuid_generate_v7()
returns uuid
as $$
begin
-- use random v4 uuid as starting point (which has the same variant we need)
-- then overlay timestamp
-- then set version 7 by flipping the 2 and 1 bit in the version 4 string
return encode(
@yinsee
yinsee / UIImage+Trim
Last active June 19, 2023 05:33
Trim whitespaces on UIImage
/*
http://stackoverflow.com/questions/9061800/how-do-i-autocrop-a-uiimage/40780523#40780523
*/
import UIKit
extension UIImage {
func trim() -> UIImage {
let newRect = self.cropRect
@rob-murray
rob-murray / upload_testflight.sh
Last active June 4, 2019 05:07
Script to upload .ipa file to Testflight
#!/bin/bash
#
# Simple script to upload .ipa to testflight
# Usage: upload_testflight.sh /path/to/file.ipa /path/to/app.dSYM {build version}
#
# src: https://gist.github.com/rob-murray/7941761
#
if [ $# -lt 3 ]
@jpwatts
jpwatts / xcode-git-version.sh
Created May 11, 2011 16:42
This Xcode 4 build phase script automatically sets the version and short version string of an application bundle based on information from the containing Git repository.
#!/bin/bash
# This script automatically sets the version and short version string of
# an Xcode project from the Git repository containing the project.
#
# To use this script in Xcode 4, add the contents to a "Run Script" build
# phase for your application target.
set -o errexit
set -o nounset