Skip to content

Instantly share code, notes, and snippets.

View NunoAlexandre's full-sized avatar

Nuno NunoAlexandre

View GitHub Profile
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
-- Support for https://nunoalexandre.com/2018/01/28/a-case-for-dependent-types
data ValueType = StringType | IntType
<?xml version="1.0" ?>
<items>
<item>
<title>IPode</level>
<price>1.15</price>
</item>
<item>
<title>iPadi</level>
<price>2.15</price>
</item>
@NunoAlexandre
NunoAlexandre / feed.xml
Last active May 1, 2018 13:22
feed.xml
<?xml version='1.0' encoding='utf-8'?>
<items>
<item>
<additional_imagelinks>http://example.com/one.jpg</additional_imagelinks>
<additional_imagelinks>http://example.com/two.jpg</additional_imagelinks>
<additional_imagelinks>http://example.com/three.jpg</additional_imagelinks>
<profit>-9.4 EUR</profit>
<comma>-9,15</comma>
<numberz>--9.77EUR</numberz>
<numberpoints>-9..77EUR</numberpoints>
### Command
``` bash
stack test --fast --test-arguments '-m "<identifier>"'
```
The `<identifier>` can be pretty much anything:
- Part of / a module's name
- A `describe` / `it` description
/// This module contains useful extensions to the base
/// navigation controllers in respect to managing orientation,
/// as well as adding missing functionality to the sdk types.
import Foundation
func currentOrientation() -> UIInterfaceOrientation {
return UIApplication.shared.statusBarOrientation
}
@NunoAlexandre
NunoAlexandre / Keychain.swift
Last active June 2, 2023 10:05
Extend 'KeychainWrapper' to store and lookup Dictionaries
import Foundation
import SwiftKeychainWrapper
let keychain: KeychainWrapper = KeychainWrapper.standard
/// Add methods that allow a client to save and lookup Dict's.
extension KeychainWrapper {
func saveDict(_ value: [String: Any], forKey key: String) {
self.set(NSKeyedArchiver.archivedData(withRootObject: value),
forKey: key)
@NunoAlexandre
NunoAlexandre / proceduralModeling.swift
Last active December 23, 2018 10:38
Procedural modeling
class Slideshow: UIViewController {
let slides: [SlideView]
init(slides: [SlideView]) {
self.slides = slides
}
// UI & Layout code goes here...
}
@NunoAlexandre
NunoAlexandre / typedModeling.swift
Last active December 23, 2018 10:51
Typed Modeling
class Slideshow: UIView {
let slides: [SlideView]
// UI & Layout code goes here...
}
class SlideView: UIView {
let slide: Slide
// UI & Layout code goes here...
@NunoAlexandre
NunoAlexandre / createSlideshowProcedural.swift
Created December 23, 2018 10:40
Create a Slideshow - Procedural Modeling
let slideshow = Slideshow(
slides: [
SlideView(index: 0),
SlideView(index: 1),
SlideView(index: 2)
]
)
@NunoAlexandre
NunoAlexandre / createSlideshowTyped.swift
Last active December 23, 2018 10:53
Create Slideshow - Typed Modeling
let slides = [
Slide(
title: "Bobby Mcferrin",
description: "Jazz at its best",
image: UIImage(name: "BobbyMcferrin")!
),
Slide(
title: "Kurt Vile",
description: "A prolific creative",
image: UIImage(name: "KurtVile")!