Skip to content

Instantly share code, notes, and snippets.

View eliotfowler's full-sized avatar

Eliot Fowler eliotfowler

View GitHub Profile
@eliotfowler
eliotfowler / WithLatestFrom.swift
Created October 10, 2019 21:09
Initial implementation of withLatestFrom for Combine
import Combine
var cancellables = [AnyCancellable]()
extension Publisher {
func withLatestFrom<A, P: Publisher>(
_ second: P
) -> AnyPublisher<A, Failure> where P.Output == A, P.Failure == Failure {
return second
.map { result -> AnyPublisher<A, Failure> in
@eliotfowler
eliotfowler / Sierpinski.playground
Last active April 28, 2020 15:03
Sierpinski Triangle in Swift
//: Sierpinski triangle - A repeating series of triangles. Each iteration subdivides an equilateral triangle into 4 smaller triangles creating a fractal pattern that is mesmerizing. This type of problem is well suited for recursion!
import UIKit
class Sierpinski: UIView {
let background = UIColor(red: 71 / 255, green: 71 / 255, blue: 71 / 255, alpha: 1)
override init(frame: CGRect) {
super.init(frame: frame)
@eliotfowler
eliotfowler / Grid.h
Created May 14, 2016 15:00
Interface for a crossword puzzle
//
// Grid.h
// Crossword
//
// Created by Eliot Fowler on 10/9/14.
// Copyright (c) 2014 Eliot Fowler. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "GridSize.h"
@eliotfowler
eliotfowler / xw.rb
Last active September 6, 2020 04:56
.puz to xpf-json converter
#!/usr/bin/env ruby
require 'json'
@filename = ARGV[0]
def read_puz(length, offset)
return IO.read(@filename, length, offset)
end
### Keybase proof
I hereby claim:
* I am EliotFowler on github.
* I am eliotfowler (https://keybase.io/eliotfowler) on keybase.
* I have a public key whose fingerprint is 4D29 FC3C 6AB9 190B E46B 326D 644F 79BF 1925 C65B
To claim this, I am signing this object:
@eliotfowler
eliotfowler / Gruntfile.js
Created May 9, 2014 14:29
Sample Gruntfile
module.exports = function (grunt) {
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Define the configuration for all the tasks
grunt.initConfig({
@eliotfowler
eliotfowler / Destination.scala
Created March 5, 2014 03:57
Url Shortener Model for Play written in Scala
package models
import anorm._
import anorm.SqlParser._
import play.api.db.DB
import play.api.Play.current
case class Destination(id: Long, originalUrl: String, shortUrlHash: String)
object Destination {