Skip to content

Instantly share code, notes, and snippets.

View lukestringer90's full-sized avatar

Luke Stringer lukestringer90

View GitHub Profile
@lukestringer90
lukestringer90 / terminal-prompt-git-branch-zsh.md
Last active January 23, 2024 18:18 — forked from reinvanoyen/terminal-prompt-git-branch-zsh.md
Add Git Branch Name to Terminal Prompt (MacOS Catalina zsh)
# --- GIT BRANCH PROMPT ---

function git_branch_name()
{
  branch=$(git symbolic-ref HEAD 2> /dev/null | awk 'BEGIN{FS="/"} {print $NF}')
  if [[ $branch == "" ]];
  then
    :
 else
@lukestringer90
lukestringer90 / codewars-5547cc7dcad755e480000004.swift
Created November 22, 2023 17:17
Solution to Code Wars 5547cc7dcad755e480000004
// Problem statement: https://www.codewars.com/kata/5547cc7dcad755e480000004/train/swift
import Foundation
func removNb(_ length: Int) -> [(Int,Int)] {
var matches = [(Int,Int)]()
var seenNumbers = [Int]()
let sumOfNumbers = ((length * length) + length) / 2
var numbersToTry = Array(Array(1...length)[1...length-1].reversed()).makeIterator()
@lukestringer90
lukestringer90 / BlueDays.swift
Last active January 20, 2022 08:21
Calculate the days in a given year that are the most or least 'Blue'
import UIKit
enum Blueness: String {
case Most, Least
}
// Print out the days in a given year that are the most or least 'Blue'
func blueDays(`in` year: Int, blueness: Blueness) {
// Generate dates for each day for the given year
@lukestringer90
lukestringer90 / pre-commit
Created September 7, 2014 13:22
Pre commit hook to run Xcode unit tests
#!/bin/sh
# A hook script to run Xcode unit tests before committing.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
WORKSPACE_PATH="path/to/your.xcworkspace"
SCHEME="scheme-name"
SDK="iphonesimulator"
@lukestringer90
lukestringer90 / gist:8ce18a4005b88e5503c2
Last active August 29, 2015 14:05
Makefile to run iOS tests from command line
PROJECT_NAME=ProjectNameHere
WORKSPACE=$(PROJECT_NAME).xcworkspace
SCHEME=$(PROJECT_NAME)
SDK=iphonesimulator
OUTPUT_PATH=test-report
DEFAULT_TASK=xcodebuild -workspace $(WORKSPACE) -scheme $(SCHEME) -sdk $(SDK) clean test | xcpretty --color ; exit ${PIPESTATUS[0]}
test:
$(DEFAULT_TASK)
@lukestringer90
lukestringer90 / gist:4693694
Last active December 12, 2015 01:48
Good iPad apps for Ken

iPad Apps for Ken

  • Pocket: A really good read it later app for stuff you want to, well, read stuff later. Universal app and has a Mac app also.
  • Evernote: Pretty good note taking app. Lets you upload images containing text and it will index them and make them searchable. App is a little sluggish at times but the note taking view has some nice text formatting options you don't see else where. Again, there is an iPhone and Mac app.
  • Flipboard: A nice RSS/news reader.
  • Youtube: Good app for YouTube, obviously. Better than Apples attempt before they killed it off in my opinion. Shame it doesn't support airplay but still good.
  • Screens: T
@lukestringer90
lukestringer90 / gist:3833592
Created October 4, 2012 13:41
Macros for NSPredicate and NSSortDescriptor
#define pred(format) [NSPredicate predicateWithFormat:format]
#define sort(key, asc) [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:key ascending:asc]]
//array of core data entities (giggle!)
NSArray *entities = (.)(.)
//filter array
NSArray *filtered = [entities filteredArrayUsingPredicate:pred(@"timestamp != nil")];