Skip to content

Instantly share code, notes, and snippets.

View konrad1977's full-sized avatar

Mikael Konradsson konrad1977

View GitHub Profile
--recurse
--exclude=.git
--exclude=venv
--exclude=Pods
--exclude=Carthage
--exclude=vendor
--exclude=node_modules
@konrad1977
konrad1977 / .spacemacs
Last active December 14, 2021 15:04
Swift support for Spacemacs (.spacemacs)
;; -*- mode: emacs-lisp; lexical-binding: t -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Layer configuration:
This function should only modify configuration layer settings."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
;; `+distribution'. For now available distributions are `spacemacs-base'
@konrad1977
konrad1977 / PlaygroundXCTest.swift
Created January 21, 2020 13:16
Unit test support in Swift Playgrounds
import XCTest
// MARK: Comparable ---
@discardableResult
public func assertGreaterThan<A: Comparable>(_ lhs: A, _ rhs: A) -> String {
return lhs > rhs ? "✅" : "❌"
}
@discardableResult
public func assertGreaterThanOrEqual<A: Comparable>(_ lhs: A, _ rhs: A) -> String {
@konrad1977
konrad1977 / kitura-helloworld.swift
Created April 9, 2017 10:16
Hello world in kitura
import Kitura
let router = Router() router.get("/") { request, response, next in
response.send("Hello, World!")
next()
}
Kitura.addHTTPServer(onPort: 8090, with: router)
Kitura.run()
@konrad1977
konrad1977 / gist:79730ac30643546c39dc
Created June 2, 2015 12:35
SameAbstrationLevel
void UpdatePersonWithId(int personId) {
Person personToFind = FindPersonWithId(personId);
if (personToFind != null)
SavePerson(personToFind);
}
void FindPersonWithId(int personId) {
Person personToFind = null;
foreach(person in personList) {
if (person.id == personId) {
@konrad1977
konrad1977 / gist:b6b8c290888e82473c9c
Last active September 20, 2016 06:51
olika_abstraktions_nivåer
void UpdatePersonWithId(int personId) {
Person personToFind = null;
foreach(person in personList) {
if (person.id == personId) {
personToFind = person;
break;
}
}
SavePerson(personToFind);
}
@konrad1977
konrad1977 / TableViewContorllerThatWorks.swift
Created March 19, 2015 10:01
Functional working tableViewController
class TableViewContorllerThatWorks: UITableViewController {
override init(style: UITableViewStyle) {
super.init(style: style)
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@konrad1977
konrad1977 / Person_v4.swift
Last active April 14, 2016 19:20
Person with Protocol
protocol AgeClasificationProtocol {
var age: Int { get }
func agetype() -> String
}
class Person {
let firstname: String
let lastname: String
var age: Int
@konrad1977
konrad1977 / login_version2.swift
Created June 14, 2015 12:13
Refactored version of login
func login() {
do {
let token = try loginUserWithUsername("konrad1977", password: nil)
print("user logged in \(token)")
} catch let error as LoginError {
print(error.description)
} catch {
print(error)
}
@konrad1977
konrad1977 / extension.swift
Created June 14, 2015 12:09
Login error extension
extension LoginError : CustomStringConvertible {
var description: String {
switch self {
case .EmptyUsername:
return "Username cannot be empty"
case .EmptyPassword:
return "Password cannot be empty"
}
}