Skip to content

Instantly share code, notes, and snippets.

View bitops's full-sized avatar

Sebastian Wittenkamp bitops

View GitHub Profile
@bitops
bitops / GifView.swift
Created November 1, 2022 22:05
A SwiftUI View that renders gifs using ImageIO
import SwiftUI
import ImageIO
struct TestGif {
static let url: URL = Bundle.main.url(forResource: "your-file-here", withExtension: "gif")!
}
struct GifView: View {
@State private var gif: UIImage
@bitops
bitops / TapPhotosInCameraPickerTests.swift
Created April 12, 2022 18:08
How to tap the pre-loaded photos in the camera roll in iOS UI test
/*
LIKE: The left hand expression equals the right-hand expression: ? and * are allowed as wildcard characters, where ? matches 1 character and * matches 0 or more characters.
Resource: https://nshipster.com/nspredicate/
*/
let yellowLeafGreenBackground = NSPredicate(format: "label LIKE 'Photo, October 09, 2009, *:09*'")
let waterfallCloseUpOverRocks = NSPredicate(format: "label LIKE 'Photo, August 08, 2012, *:29*'")
let treeWithWaterfallBackground = NSPredicate(format: "label LIKE 'Photo, August 08, 2012, *:52*'")
let yellowFlowerSucculentBeach = NSPredicate(format: "label LIKE 'Photo, March 12, 2011, *:17*'")
let amazingWaterfall = NSPredicate(format: "label LIKE 'Photo, August 08, 2012, *:55*'")
@bitops
bitops / settings.json
Created December 22, 2020 08:34
VS Code setting to insert newlines at the end of files
{
"files.insertFinalNewline": true
}
@bitops
bitops / BlurViewController.swift
Last active August 11, 2020 21:24
UIViewController that frosts a portion of the screen. The `toggleBlur` method is hooked up to a button on the story board.
class BlurViewController: UIViewController {
var blurView : UIVisualEffectView!
override func viewDidLoad() {
let frame = CGRect(x: view.bounds.maxX * 0.1, y: view.bounds.maxY * 0.4, width: 350, height: 200)
blurView = UIVisualEffectView(frame: frame)
blurView.effect = UIBlurEffect(style: .systemUltraThinMaterial)
view.addSubview(blurView)
}
@bitops
bitops / fp-lingo.md
Created October 12, 2019 04:09 — forked from ericelliott/fp-lingo.md
A Guide to Functional Programming Lingo for JavaScripters

A Guide to Functional Programming Lingo for JavaScripters

Functional programming gets a bad wrap about being too hard for mere mortals to comprehend. This is nonsense. The concepts are actually quite simple to grasp.

The jargon is the hardest part. A lot of that vocabulary comes from a specialized field of mathematical study called category theory (with a liberal sprinkling of type theory and abstract algebra). This sounds a lot scarier than it is. You can do this!

All examples using ES6 syntax. wrap (foo) => bar means:

function wrap (foo) {
@bitops
bitops / mapQueryReplaceRegex.js
Last active September 7, 2019 21:38
A javascript implementation of the `map-query-replace-regexp` command from Emacs, using Ramda
const mapQueryReplaceRegex = (regex, data, tokens) => {
const token = R.head(tokens)
const transform = R.replace(regex, token, data)
if(transform === data) {
return transform
} else {
const nextTokens = R.concat(R.tail(tokens), [token])
return mapQueryReplaceRegex(regex, transform, nextTokens)
}
// pipe-forward operator
precedencegroup ForwardApplication {
associativity: left
}
infix operator |>: ForwardApplication
func |> <A, B>(a: A, f: (A) -> B) -> B {
return f(a)
}
@bitops
bitops / richhickey.md
Created April 18, 2018 03:18 — forked from prakhar1989/richhickey.md
richhickey.md

Rich Hickey on becoming a better developer

Rich Hickey • 3 years ago

Sorry, I have to disagree with the entire premise here.

A wide variety of experiences might lead to well-roundedness, but not to greatness, nor even goodness. By constantly switching from one thing to another you are always reaching above your comfort zone, yes, but doing so by resetting your skill and knowledge level to zero.

Mastery comes from a combination of at least several of the following:

@bitops
bitops / blue_green.sh
Created March 13, 2018 14:42
Simple blue-green cloud foundry deploy script
#!/bin/bash
echo "Building app."
mvn clean package
echo "Pushing Blue."
cf push seb -f manifest.yml
echo "Pushing Green."
cf push seb-green -f manifest.yml
@bitops
bitops / Program.cs
Created August 3, 2017 18:38
Simple XmlDocument example with Couchbase on .Net
using System;
using System.IO;
using System.Threading;
using System.Xml;
using Couchbase;
namespace ConsoleApp1
{
class Program
{