Skip to content

Instantly share code, notes, and snippets.

View tristandl's full-sized avatar

Tristan Ludowyk tristandl

View GitHub Profile
@tristandl
tristandl / gist:885d42a4c8cecce7e2439456e8c3da22
Created February 9, 2021 05:20
alias to create a new branch with username/date prefix
git config --global alias.bc '!f() { git switch -c `whoami`/`date +"%Y%m%d"`-$1; }; f'
@tristandl
tristandl / mapInvoke.swift
Last active January 26, 2019 05:24
map over object instances, invoking methods on them in Swift
extension Sequence {
func map<T>(invoking transform: (Self.Element) throws -> () -> T) rethrows -> [T] {
return try map { try transform($0)() }
}
}
@tristandl
tristandl / todos-as-warnings.sh
Last active April 16, 2018 08:39
# Highlights TODO: and FIXME: comments but ignores any comments from 3rd party Pods. Thanks to Hector Matos https://krakendev.io/blog/generating-warnings-in-xcode
TAGS="TODO:|FIXME:"
ERRORTAG="ERROR:"
find "${SRCROOT}" -path "${SRCROOT}"/Pods -prune -o -path "${SRCROOT}"/vendor -prune -o \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$|($ERRORTAG).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/" | perl -p -e "s/($ERRORTAG)/ error: \$1/"
/*
* This will convert DateTime (.NET) object serialized as JSON by WCF to a NSDate object.
*/
// Input string is something like: "/Date(1292851800000+0100)/", "\/Date(1292851800000-0100)\/" or "/Date(1292851800000)/" where
// 1292851800000 is milliseconds since 1970 and +0100 is the timezone
NSString *inputString = [item objectForKey:@"DateTimeSession"];
// This will tell number of seconds to add according to your default timezone
// Note: if you don't care about timezone changes, just delete/comment it out