Skip to content

Instantly share code, notes, and snippets.

View skreutzberger's full-sized avatar

Sebastian Kreutzberger skreutzberger

View GitHub Profile
@skreutzberger
skreutzberger / relativeDateInterval.swift
Last active April 17, 2023 12:32
Swift 2 function for human-readable time interval
/// returns optional relative date interval string like "2d"
/// depending on the unitsstyle, see docs at http://apple.co/1ox2sOX
/// inject an existing NSDateComponentsFormatter() for performance
func relativeDateInterval(date: NSDate,
unitsStyle: NSDateComponentsFormatterUnitsStyle,
formatter: NSDateComponentsFormatter) -> String? {
// inspired by top answer at http://bit.ly/1TzMQqV
let formatter = NSDateComponentsFormatter()
formatter.unitsStyle = unitsStyle //.Abbreviated, .Full, ...
formatter.includesApproximationPhrase = false
@skreutzberger
skreutzberger / python-dev-berlin.md
Created August 27, 2012 12:05
Senior Python Developer Berlin

#Open Position "Senior Python Developer Berlin"

For our stealth high-tech cloud startup in Berlin, I am searching for a capable member for our team of backend hackers. The main tasks would be writing tools for automation, deployment and scaling of multiple cloud providers. We are also working on Big Data, where the tasks are mostly data mining and processing (Map/Reduce).

In general, it is a technically very challenging high-tech position. That’s why we are looking for experienced backend hackers with a flexible mindset and skills in software design, coding and server administration (in the ratio of 10:70:20) and a reputation in the open source community.

Required professional experience:

  • Python and another web language
  • PostgreSQL & NoSQL databases
@skreutzberger
skreutzberger / randomEmail.swift
Created August 12, 2015 14:17
generate random email adddress in Swift
// returns a random email as string
func randomEmail() -> String {
let nameLength = randomInt(5, to: 10)
let domainLength = randomInt(5, to: 10)
let domainSuffixes = ["com", "net", "org", "io", "co.uk"]
let name = randomText(nameLength, justLowerCase: true)
let domain = randomText(domainLength, justLowerCase: true)
let randomDomainSuffixIndex = Int(arc4random_uniform(UInt32(domainSuffixes.count)))
let domainSuffix = domainSuffixes[randomDomainSuffixIndex]
let text = name + "@" + domain + "." + domainSuffix
@skreutzberger
skreutzberger / emoji-console.swift
Created September 20, 2016 06:15
Colored level emojis in Xcode 8 & Swift 2.3
// set custom level strings to add color
let console = ConsoleDestination()
console.levelString.Verbose = "💜 VERBOSE"
console.levelString.Debug = "💚 DEBUG"
console.levelString.Info = "💙 INFO"
console.levelString.Warning = "💛 WARNING"
console.levelString.Error = "❤️ ERROR"
@skreutzberger
skreutzberger / randomColor.swift
Created August 12, 2015 14:38
generate random color in Swift
// returns a random color
func randomColor() -> UIColor{
let red = CGFloat(drand48())
let green = CGFloat(drand48())
let blue = CGFloat(drand48())
return UIColor(red: red, green: green, blue: blue, alpha: 1.0)
}
@skreutzberger
skreutzberger / randomText.swift
Created August 12, 2015 13:53
generate random text in Swift
// returns random text of a defined length
// optional bool parameter justLowerCase
// to just generate random lowercase text
func randomText(length: Int, justLowerCase: Bool = false) -> String {
var text = ""
for _ in 1...length {
var decValue = 0 // ascii decimal value of a character
var charType = 3 // default is lowercase
if justLowerCase == false {
// randomize the character type
@skreutzberger
skreutzberger / sen_swiftbe_dev.md
Last active December 2, 2019 15:07
Senior Swift Backend Developer (Freelance, 100% Remote)

Senior Swift Backend Developer (Freelance, 100% Remote)

I am searching experienced backend developers (freelance, remote) with a ❤️ for Swift for Moonshot Energy, the world’s first AI-driven renewable energy company located in Germany. Moonshot Energy is financially backed by Innogy SE, one of Europe's largest energy providers.

At Moonshot you will play a major role in making the world greener, the future brighter and energy distribution smarter by using latest technologies like server-side Swift, microservices, artificial intelligence 🤖 and machine learning and new interfaces like chatbots and dialog-based systems (NLP).

Since our team is working on European timezones it would be good if you would live in the EU or if you are an early bird living in US-East 🇪🇺🇺🇸.

Your job:

  • build our internal microservices
@skreutzberger
skreutzberger / sen_ios_swift_dev.md
Last active December 6, 2018 20:49
Senior iOS Swift Developer (Freelance, 100% Remote)

Senior iOS Swift Developer (Freelance, 100% Remote, EU)

I am searching experienced Swift freelancers for a disruptive, well-funded high-tech startup in the renewable energies sector located in Germany.

You will play a major role in making the world greener, the future brighter and energy distribution smarter by using latest technologies like server-side Swift, microservices, artificial intelligence and machine learning and new interfaces like chatbots, voice-only (Alexa, Google Home) and goal-driven dialog systems.

A substantial track record in open-source projects, a set of already released iOS apps on the App Store and a timezone difference of max 2 hours to Berlin local time are a must-have.

Your job:

  • build our chat-based iOS app and optionally later the Android app
@skreutzberger
skreutzberger / getICloudUserID.swift
Last active August 31, 2018 04:13
get iCloud User ID
import CloudKit
/// async gets iCloud record ID object of logged-in iCloud user
func iCloudUserIDAsync(complete: (instance: CKRecordID?, error: NSError?) -> ()) {
let container = CKContainer.defaultContainer()
container.fetchUserRecordIDWithCompletionHandler() {
recordID, error in
if error != nil {
print(error!.localizedDescription)
complete(instance: nil, error: error)
@skreutzberger
skreutzberger / calliCloudUserIDAsync.swift
Created November 27, 2015 09:07
use iCloudUserIDAsync
import CloudKit
iCloudUserIDAsync() {
recordID, error in
if let userID = recordID?.recordName {
print("received iCloudID \(userID)")
} else {
print("Fetched iCloudID was nil")
}
}