Skip to content

Instantly share code, notes, and snippets.

View Bersaelor's full-sized avatar
🏠
Working from home

Konrad Feiler Bersaelor

🏠
Working from home
View GitHub Profile
@Bersaelor
Bersaelor / ShadowLabelNode.swift
Created August 16, 2018 11:21
ShadowLabelNode
// based on objective-c code Erica Sadun: https://github.com/erica/useful-things
import SpriteKit
fileprivate let shadowEffectNodeKey = "ShadowEffectNodeKey"
class ShadowLabelNode: SKLabelNode {
var offset : CGPoint = CGPoint(x: 1, y: -1) {
didSet { updateShadow() }
}
@Bersaelor
Bersaelor / Matrix4+Extensions.swift
Last active September 11, 2020 07:58
Applying SCNMatrix4 to SCNVector3 (Couldn't find this in SceneKit)
//
// Matrix4+Extensions.swift
// StARs
//
// Created by Konrad Feiler on 17.12.17.
// Copyright © 2017 Konrad Feiler. All rights reserved.
//
import Foundation
import SceneKit
@Bersaelor
Bersaelor / ButtonNode
Last active December 8, 2017 11:02
SpriteKit Node functioning as a UIButton like node
//
// ButtonNode.swift
// StARs
//
// Created by Konrad Feiler on 07.12.17.
// Copyright © 2017 Konrad Feiler. All rights reserved.
//
import SpriteKit
@Bersaelor
Bersaelor / main.swift
Created September 26, 2017 14:24
Example app Swift4, crashes when run on Linux environment with concurrency > 1
import Foundation
import Dispatch
guard CommandLine.arguments.count > 1 else {
print("Please add one argument for the number of lanes")
exit(0)
}
var maxConcurrency = Int(CommandLine.arguments[1]) ?? 1
print("Starting to fetch with max \(maxConcurrency) simultaneous fetches")
@Bersaelor
Bersaelor / smoothsort.swift
Created March 26, 2017 15:52 — forked from kazk/smoothsort.swift
Smoothsort in Swift
// Swift3 adaption of https://gist.github.com/kazk/5c660d071642193f5301 by https://github.com/kazk
// An implementation of [Smoothsort] algorithm invented by Edsger Dijkstra,
// which I didn't get until reading [Smoothsort Demystified] by Keith Schwarz.
//
// Some optimizations like the chained swaps and corner case elimination were
// derived from [smoothsort.c] by Martin Knoblauch Revuelta.
func smoothsort<T : Comparable>( a: inout [T]) {
smoothsort(&a) { $0 < $1 }
@Bersaelor
Bersaelor / 0_reuse_code.js
Created August 22, 2016 07:33
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@Bersaelor
Bersaelor / LocalizedFormatting.playground
Last active February 8, 2016 10:30
Demonstrates localized NSDateFormatter behaviour
//: Playground - noun: a place where people can play
import UIKit
let date = NSDate()
let number = 29.23
let heightInm = 1.87
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "yyyy"
enum Fonts {
case H1
case H2
case H3
case SomethingElse(value: String)
var jsonKey: String {
switch self {
case H1:
return "H1"