Skip to content

Instantly share code, notes, and snippets.

View elkraneo's full-sized avatar
🌍

Cristian Díaz elkraneo

🌍
View GitHub Profile
@AdrianBinDC
AdrianBinDC / MapRegionUtility.swift
Last active May 19, 2023 01:13
Generate a MKCoordinateRegions for continents and major oceans
//
// MapRegionUtility.swift
// QuakeData
//
// Created by Adrian Bolinger on 7/9/18.
// Copyright © 2018 Adrian Bolinger.
//
/*
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// Angle+Trig.swift
// SwiftPlaneGeometry
#if os(Linux)
/// #error No Linux Support
#else
import Darwin
#endif
extension Angle {
@inamiy
inamiy / SwiftElmFrameworkList.md
Last active March 11, 2024 10:20
React & Elm inspired frameworks in Swift
enum DateStride {
case year(Int)
case month(Int)
case day(Int)
var component: Calendar.Component {
switch self {
case .year(_):
return .year
@patriciogonzalezvivo
patriciogonzalezvivo / toGif.sh
Created February 12, 2017 14:57
Frag Shader to gif
#!/bin/bash
SHADER=$1
SEC=$1
COUNTER=0
for i in `seq -w 0.01 .031 $SEC`; do
echo $i
`glslViewer $SHADER -s $i -o frame-$COUNTER.png`
let COUNTER=COUNTER+1
@CliffordAnderson
CliffordAnderson / berlin-wall.geojson
Last active November 13, 2018 09:32
Berlin Wall GeoJSON converted from Open Street Maps
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zwaldowski
zwaldowski / Activity.swift
Last active February 15, 2024 18:49
os_activity_t for Swift 3
//
// Activity.swift
//
// Created by Zachary Waldowski on 8/21/16.
// Copyright © 2016 Zachary Waldowski. Licensed under MIT.
//
import os.activity
private final class LegacyActivityContext {
public extension Int {
public var seconds: DispatchTimeInterval {
return DispatchTimeInterval.seconds(self)
}
public var second: DispatchTimeInterval {
return seconds
}
@maxcampolo
maxcampolo / NativeWebView.swift
Created July 28, 2016 13:58
WKWebView setup to make a web page adopt native behavior.
import WebKit
class NativeWebViewController: UIViewController {
let viewportScriptString = "var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); meta.setAttribute('initial-scale', '1.0'); meta.setAttribute('maximum-scale', '1.0'); meta.setAttribute('minimum-scale', '1.0'); meta.setAttribute('user-scalable', 'no'); document.getElementsByTagName('head')[0].appendChild(meta);"
let disableSelectionScriptString = "document.documentElement.style.webkitUserSelect='none';"
let disableCalloutScriptString = "document.documentElement.style.webkitTouchCallout='none';"
override func viewDidLoad() {
// 1 - Make user scripts for injection
@andymatuschak
andymatuschak / States-v3.md
Last active May 1, 2024 12:32
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,