Skip to content

Instantly share code, notes, and snippets.

View NxSoftware's full-sized avatar

Steve Wilford NxSoftware

View GitHub Profile
@NxSoftware
NxSoftware / Geocoder.swift
Created February 4, 2019 14:25
Swift Geocoder
let geocoder = CLGeocoder()
let location = CLLocation(latitude: 47.640320, longitude: -122.134400)
geocoder.reverseGeocodeLocation(location) { (addressList, error) in
if let error = error {
print("Unable to Reverse Geocode Location (\(error))")
} else {
print(addressList?.first?.compactAddress ?? "No Matching Addresses Found")
}
}
@NxSoftware
NxSoftware / MSBuildSnippet.csproj
Created January 3, 2018 11:23
MSBuild copy files to output
<ItemGroup>
<_FilesToBeCopied Include="$(ProjectDir)\SourceDirectory\**\*.extension" />
</ItemGroup>
<Target Name="CopyFiles" AfterTargets="build">
<Copy SourceFiles="@(_FilesToBeCopied)"
DestinationFolder="$(OutputPath)\TargetDirectory\%(RecursiveDir)"
SkipUnchangedFiles="false"
OverwriteReadOnlyFiles="true"
Retries="3"
RetryDelayMilliseconds="300" />
@NxSoftware
NxSoftware / swiftkata.rb
Last active January 2, 2017 16:16
Generates a Swift package for writing katas and guard for running tests
#!/usr/bin/ruby
kata_name = ARGV[0]
if kata_name == nil then
puts "You must provide a Kata name."
exit
end
LICENSEFILE = %Q{MIT License
@NxSoftware
NxSoftware / domoticzBackup.sh
Created September 17, 2016 16:10
Domoticz Backup script
#!/bin/bash
BACKUP_SERVER=mac-mini-server.local
BACKUP_PORT=2222
BACKUP_USERNAME=domoticz
DOMOTICZ_SERVER=127.0.0.1
DOMOTICZ_PORT=8080
DOMOTICZ_DIR="/home/pi/domoticz"
DOMOTICZ_WWW_DIR="$DOMOTICZ_DIR/www"
Expand file-system to allow access to the entire SD card
sudo raspi-config
--
Enable SSH and logging
sudo nano /etc/init.d/domoticz.sh
@NxSoftware
NxSoftware / pre-commit
Last active September 1, 2016 08:26
git pre-commit hook to prevent committing files that contain a certain string
#!/bin/sh
git diff-index --name-status --cached HEAD -- | cut -c3- | while read FILE
do
if git diff --cached "$FILE" | grep -q "^+[^+].*// NOCOMMIT"; then
echo $FILE ' contains a NOCOMMIT string!'
exit 1
fi
done
@NxSoftware
NxSoftware / Git amend author
Created July 15, 2016 19:34
Amends authors of git commits
# --root to change first commit as well
git rebase -i --root
git commit --amend --author "Steve Wilford <steve@stevewilford.co.uk>"
git rebase --continue
@NxSoftware
NxSoftware / SourceTree-GitLab.sh
Created June 15, 2016 13:34
SourceTree Open in GitLab custom action
#!/bin/bash
REPO_DIR=$1
SHA=$2
cd $REPO_DIR
GITLAB_URL=`git remote get-url origin | sed -e 's/git@//' -e 's/:/\//' -e 's/\.git//'`
open "https://$GITLAB_URL/commit/$SHA"
@NxSoftware
NxSoftware / list-deleted-stashes.sh
Created February 19, 2016 22:19
List deleted git commits/stashes
git log --graph --oneline --decorate $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )
#git stash apply $SHA
@NxSoftware
NxSoftware / XCTestCase+OffTopic.swift
Created November 21, 2015 13:30
XCTestCase extension for simplifying waiting for expectations
//
// XCTestCase+OffTopic.swift
//
// Created by Steve Wilford on 21/11/2015.
// Copyright © 2015 Off Topic. All rights reserved.
//
import XCTest
extension XCTestCase {