Skip to content

Instantly share code, notes, and snippets.

View jwhitley's full-sized avatar
🏝️
balearic

John Whitley jwhitley

🏝️
balearic
View GitHub Profile
@jwhitley
jwhitley / repotest.zsh
Last active January 14, 2024 17:59
Shell script that replicates lazygit repo_paths_test.go scenarios
#!/bin/zsh
startPath=`pwd`
setupTmpdir() {
relTmpDir=`mktemp -d /tmp/lazygitRepoPath.XXXXXX`
TMPDIR=`realpath "$relTmpDir"`
cd $TMPDIR
}

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
// This is a "rough sketch" pulled from our application that shows how we use
// RxBluetoothKit and Nordic's DFU library together. It's more than
// pseudocode, yet not standalone, rigorously tested running code. A lot of
// details are simplified or omitted here, e.g. any device-specific details
// you may require, implementations for Nordic's DFU delegate protcols, etc.
import iOSDFULibrary // Nordic's DFU Library
import RxBluetoothKit
enum ExampleDeviceService: String, ServiceIdentifier {
@jwhitley
jwhitley / firebase-sandbox.md
Created January 11, 2017 19:08 — forked from cohenadair/firebase-sandbox.md
Setting up development and production Firebase environments for iOS

Firebase Environments

At the time of writing this gist (January 4th, 2017), I was unable to find true sandboxing to separate development and production environments for a Firebase project. The closest we can get is to create two separate Firebase projects -- one for development and one for production.

Pros

  • Complete separation and isolation of all Firebase features.
  • Freedom to experiment without risking the corruption of production data.

Cons

  • There is no way to copy production data to your development project (that I am aware of).
  • Any settings changes made to your development project also needs to be manually applied to your production project.
@jwhitley
jwhitley / ArraySlice+SetBytes.swift
Created December 24, 2016 02:16
Swift 3 ArraySlice setBytes extension
import Foundation
extension ArraySlice {
// Overwrites the ArraySlice region with the passed-in array of bytes
mutating func setBytes(_ from: [UInt8]) {
var fromIter = from.makeIterator()
self.withUnsafeMutableBytes { bytes in
for i in stride(from: bytes.startIndex, to: bytes.endIndex - 1, by: 1) {
if let fromByte = fromIter.next() {
bytes[i] = fromByte
#!/bin/sh
git -c color.status=always status -s | sed "1s/^/$*\\
/"
@jwhitley
jwhitley / ssh_config_for_vagrant
Created February 11, 2015 17:56
Convenience SSH host config for Vagrant VMs
Host vagrant
User vagrant
HostName 127.0.0.1
Port 2222
Compression yes
PubkeyAuthentication yes
LogLevel FATAL
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
IdentitiesOnly yes
set deviceID to (do shell script "diskutil list | awk '/YourBootcampPartition/ {print $NF}'")
do shell script "sudo bless -device /dev/" & deviceID & " -legacy -setBoot -nextonly"
tell application "Finder" to restart
@jwhitley
jwhitley / git-embargo
Created October 4, 2013 20:03
git-embargo
#!/usr/bin/env zsh
# This is a utility wrapper around git update-index used to mark, unmark, and
# list files that are marked with the assume-unchanged bit. See `git help
# update-index` for details.
#
# Usage:
# git embargo <FILE> # Mark a file as embargoed -- changes won't appear in status
# git embargo -r <FILE> # Remove the embargo
# git embargo -l|--list # List all embargoed files
@jwhitley
jwhitley / custom.rb
Created June 22, 2012 07:14
Sample VM user-customization Chef recipe
include_recipe "git"
%w{ vim zsh }.each { |p| package p }
bash "Set vagrant's shell to zsh" do
code <<-EOT
chsh -s /bin/zsh vagrant
EOT
not_if 'test "/bin/zsh" = "$(grep vagrant /etc/passwd | cut -d: -f7)"'
end