Skip to content

Instantly share code, notes, and snippets.

View huwr's full-sized avatar
🏡
Working from home

Huw Rowlands huwr

🏡
Working from home
View GitHub Profile
@huwr
huwr / NavFunApp.swift
Last active March 23, 2023 04:09
FB12076468
import SwiftUI
/*
In Xcode 14.3 RC1, running against iOS 16.4:
When you run this app, the first and second screens show fine. When you tap the last "Third Presentation" button, the last
screen should slide on.
For some reason, if you have the last few lines uncommented (the ones which mention SFSafariViewController, when you
tap the "Third Presentation" button, the app locks up and the CPU goes to 100%.
@huwr
huwr / Publisher+shareReplayOnce.swift
Created August 26, 2021 04:51
Combine Publisher share replace once
public extension Publisher {
/// A variation on [share()](https://developer.apple.com/documentation/combine/publisher/3204754-share)
/// that allows for buffering and replaying a single event to future subscribers.
///
/// - Parameter initialValue: The initial value of the buffer, if none has been emitted before.
/// - Returns: A publisher that replays the event to future subscribers.
func shareReplayOnce(initialValue: Output) -> Publishers.Autoconnect<Publishers.Multicast<Self, CurrentValueSubject<Output, Failure>>> {
multicast { CurrentValueSubject(initialValue) }
.autoconnect()
//
// main.swift
// timestamp
//
// Created by Huw Rowlands on 24/3/18.
// Copyright © 2018 Huw Rowlands. All rights reserved.
//
import Foundation
@huwr
huwr / repeat.sh
Created May 19, 2017 06:19
Do until success
#!/bin/bash
#Do until success...
until $*; do
sleep 0.1;
done
@huwr
huwr / Date+SunriseAndSunset.swift
Last active November 25, 2022 01:30
Swift Sunrise and Sunset calculation
//
// NSDate+SunriseAndSunset.swift
// Codiad
//
// Created by Huw Rowlands on 26.1.2016.
// Copyright © 2016 Huw Rowlands. All rights reserved.
//
import Foundation
import CoreLocation
@huwr
huwr / tfn_validator.rb
Last active August 29, 2015 14:01
Australian TFN validator
#Algorithm for working out the validity of an Australian Tax File Number.
#
#The algorithm is 'public domain', according to an ANAO report in 1999: Management of Tax File Numbers by the Australian National Audit Office, 1999 (ISBN 0 644 38866 8)
#
#See: http://bioinf.wehi.edu.au/folders/fred/tfn.html
#
#An example TFN: 123 456 782
WEIGHTS = [1, 4, 3, 7, 5, 8, 6, 9, 10]
%Make date format of \today command Australian.
%sc and old style figures
\renewcommand{\today}{
\oldstylenums{\number\day}\space
\ifcase\month\or
\sc{January}\or \sc{February}\or \sc{March}\or \sc{April}\or
\sc{May}\or \sc{June}\or \sc{July}\or \sc{August}\or \sc{September}\or
\sc{October}\or \sc{November}\or \sc{December}
\fi\space
\oldstylenums{\number\year}
@huwr
huwr / X-words.md
Last active January 2, 2016 08:49
All words containing X

X-Words

From usr/share/dict/words

  • abaxial
  • abaxile
  • abox
  • abrasax
  • abraxas
@huwr
huwr / agreement.md
Created January 6, 2014 04:50
agreement.md

Residential Lodging Agreement

This residential lodging agreement is made between \lessor\ (the lessor) and \lessee\ (the lessee), who is lodging at the premises of \address.

Rent and Bond

  1. The rent is \rent\ per week.
@huwr
huwr / agreement.tex
Last active January 2, 2016 08:29
A Residential Lodging Agreement I made with a lodger in 2012. A few mistakes...
% XeLaTeX can use any Mac OS X font. See the setromanfont command below.
% Input to XeLaTeX is full Unicode, so Unicode characters can be typed directly into the source.
% The next lines tell TeXShop to typeset with xelatex, and to open and save the source with Unicode encoding.
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[12pt]{article}
\usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots.