Skip to content

Instantly share code, notes, and snippets.

View fdstevex's full-sized avatar

stevex fdstevex

View GitHub Profile
@fdstevex
fdstevex / gist:af1c0a13a5e6ce696bf0
Last active August 3, 2017 16:31
Auto layout in playground
// Auto layout in a Swift Playground (for iOS).
import UIKit
var v = UIView()
v.frame = CGRectMake(0, 0, 200, 200)
var b1 = UIButton()
b1.setTitle("Click Me", forState:UIControlState.Normal)
b1.setTitleColor(UIColor.blueColor(), forState: UIControlState.Normal)
@fdstevex
fdstevex / Diff.xcplayground
Created June 15, 2015 12:12
Xcode Playground showing a Swift diffing algorithm suitable for performing delta updates to a WKInterfaceTable
// arr1 is the current list
// arr2 is the new list
// the insert and delete callbacks will be called - pass these
// through to WKInterfaceTable to perform a delta update
func diff<T: Comparable>(arr1: Array<T>, var arr2: Array<T>, insertFunc: (index: Int, item: T) -> Void, deleteFunc: (Int) -> Void) {
var idx1 = 0
var idx2 = 0
while (idx1 < arr1.count) {
// identical items; step to next one
if (idx2 < arr2.count && arr1[idx1] == arr2[idx2]) {
import SwiftUI
import PlaygroundSupport
struct SignUpView: View {
@State var username = ""
@State var password = ""
var body: some View {
NavigationView {
@stzsch
stzsch / Dockerfile
Last active March 12, 2023 19:54
text-generation-webui-docker
FROM python:3.10-slim
# set bash as current shell
RUN chsh -s /bin/bash
SHELL ["/bin/bash", "-c"]
# Install necessary packages
RUN apt-get update && \
apt-get install -y wget git