Skip to content

Instantly share code, notes, and snippets.


Jack Newcombe jnewc

Block or report user

Report or block jnewc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
# Fixes error:
# git: 'secrets' is not a git command. See 'git --help'.
# More information:
brew install git
jnewc / NotesApp.swift
Last active Nov 30, 2019
A notes app written in >100 lines of swift using SwiftUI
View NotesApp.swift
// ContentView.swift
// Listomania
// Created by Jack Newcombe on 05/06/2019.
// Copyright © 2019 Jack Newcombe. All rights reserved.
import SwiftUI

swiftver - Swift versioning scheme

Currently Swift modules are mostly consumed using semantic versioning (i.e. using SPM or Cocoapods).

This scheme is a revised version of semantic versioning that links the major version of the latest Swift toolchain that the


MAJOR - Incremented when the project is updated to a new Swift language version. e.g. For Swift 4, this would be '4'.

jnewc / ConditionalExecutionOperators.swift
Last active Jun 28, 2017
Conditional Execution Operators
View ConditionalExecutionOperators.swift
/// Conditional execution operators
/// For a given argument:
/// * if the argument is truthy (i.e. true or non-nil), execute closure
/// * if the argument is falsy (i.e. false or nil), do not execute the closure
infix operator => : NilCoalescingPrecedence
public func =>(state: Bool, closure: @autoclosure () -> ()) {
if state { closure() }
jnewc / Logger.swift
Last active Feb 22, 2017
Class-based logger as a protocol extension
View Logger.swift
import Foundation
import Rainbow
public enum LogLevel: UInt {
case none = 0b0000
case debug = 0b0001
case info = 0b0011
case warn = 0b0111
case error = 0b1111
jnewc / NilRejectionExample.swift
Last active Feb 8, 2017
Nil-rejection operator example
View NilRejectionExample.swift
infix operator !! : NilCoalescingPrecedence
func !!<UnwrappedType: Any, ErrorType: Error>(lhs: Optional<UnwrappedType>, rhs: ErrorType) throws -> UnwrappedType {
guard let unwrappedValue = lhs else {
throw rhs
return unwrappedValue
jnewc / i2c_test.c
Last active Jul 17, 2018
i2c analog stick driver
View i2c_test.c
* i2c_test.c
#include <linux/slab.h> /* kzalloc */
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* KERN_INFO */
#include <linux/timer.h> /* timer_list */
#include <linux/workqueue.h> /* schedule_work */
jnewc / reggie-gpio-keys.c
Created Apr 29, 2016
Reggie's gpio-keys driver
View reggie-gpio-keys.c
// Reggie added, simple gpio keys polled driver, adds button support via gpio
// will be useful for embedded devices, see gpio-mouse, gpio-fan and rotary-encoder
// for other examples of gpio access to devices from the linux kernel
// this will use GPIO4,17,21,22 as a simple test, they will be set to active_low
// so should have a pullup added to each pin and button tied to ground.
// We have to use polled at the moment because the current kernel doesn't have
// code to handle an interrupt driven gpio-keys driver, which would've been much nicer
// you should check the wiki to make sure that these gpio are correctly configured
// and see whether they are physically pulled up on the schematic, if they're not
// add a 10k pullup to the gpio-keys pins and tie the button to gnd
jnewc / elevator-saga-simple
Last active Aug 29, 2015
Elevator Saga Simple Algorithm ( < Challenge 6)
View elevator-saga-simple
init: function(elevators, floors) {
var findElevator = function() {
return _.find(elevators, function(e) { return e.loadFactor() < 0.5; });
var setupFloor = function(floor) {
floor.on('up_button_pressed', function(floorNum) {
console.log("UP: ", this.level);
You can’t perform that action at this time.