Skip to content

Instantly share code, notes, and snippets.

@rbresjer
rbresjer / gist:c6ddf40781ec019c2936cc38ddd79392
Last active November 14, 2016 11:56
Functional Swift vs non-functional Swift
///////////////////////////////////////
// - Non-functional
///////////////////////////////////////
var buffer: [Match] = []
var bufferDate: Int = 0
var sections: [FeedSection] = []
for match in matches {
if bufferDate != match.createdAt.dateInt {
if let firstMatch = buffer.first {
@rbresjer
rbresjer / LogManager.swift
Created January 2, 2017 10:30
Simple logger for Swift
//
// LogManager.swift
//
// Created by Rutger Bresjer on 30/11/2016.
// Copyright © 2016 Woost. All rights reserved.
//
import Foundation
import RxSwift
@rbresjer
rbresjer / FaqViewModel.swift
Last active January 25, 2017 14:18
Dynamic content with NSLocalizedString
import Foundation
struct FaqCategory: Equatable {
let id: Int
let name: String
let items: [FaqItem]
}
func ==(lhs: FaqCategory, rhs: FaqCategory) -> Bool {
return lhs.id == rhs.id
}
@rbresjer
rbresjer / UIColor+Ext.swift
Created January 26, 2017 19:01
UIColor extension with hex initializers
fileprivate extension UIColor {
convenience init(red: Int, green: Int, blue: Int) {
assert(red >= 0 && red <= 255, "Invalid red component")
assert(green >= 0 && green <= 255, "Invalid green component")
assert(blue >= 0 && blue <= 255, "Invalid blue component")
self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1.0)
}
convenience init(red: Int, green: Int, blue: Int, opacity: CGFloat) {
@rbresjer
rbresjer / UIColor+Ext.swift
Created January 26, 2017 19:09
UIColor extension with app color palette
extension UIColor {
static var appPrimary: UIColor {
return UIColor(hex: 0x9B26AF)
}
static var appPrimaryDark: UIColor {
return UIColor(hex: 0x7A1EA1)
}
static var appPrimaryDarkest: UIColor {
@rbresjer
rbresjer / UIFont+Ext.swift
Created January 26, 2017 19:17
UIFont extension with app font initializers
fileprivate extension UIFont {
static func lightFont(ofSize size: CGFloat) -> UIFont {
return R.font.latoLight(size: size)!
}
static func font(ofSize size: CGFloat) -> UIFont {
return R.font.latoRegular(size: size)!
}
static func boldFont(ofSize size: CGFloat) -> UIFont {
@rbresjer
rbresjer / UIFont+Ext.swift
Created January 26, 2017 19:21
UIFont extension with app font scheme
extension UIFont {
static var appHeader: UIFont {
return .boldFont(ofSize: 18)
}
static var appBody: UIFont {
return .font(ofSize: 14)
}
static var appButton: UIFont {
@rbresjer
rbresjer / LocationService.swift
Created July 13, 2017 12:44
Get the current user location with a desired accuracy, or the best possible within a set time-out
//
// LocationService.swift
//
// Created by Rutger Bresjer on 13/07/2017.
// Copyright © 2017 Woost. All rights reserved.
//
/*
Dependencies:
- RxSwift
@rbresjer
rbresjer / ViewController.swift
Created March 1, 2018 11:01
Example of EventKit/Calendar permission crash
/*
How to reproduce crash:
1. Toggle switch on, Calendar authorization is requested, grant authorization
2. Switch to the Settings app, disable Calendar authorization
3. The app crashes
Or:
1. Toggle switch on, Calendar authorization is requested, reject authorization
2. Toggle the switch on again, an alert is shown that you should authorize in the Settings app
3. Go to the Settings app, enable Calendar authorization
@rbresjer
rbresjer / README.md
Created March 14, 2019 16:28 — forked from maqnouch/README.md
Signal Installation Steps

Signal Server Installation Guide

Author: Aqnouch Mohammed aqnouch.mohammed@gmail.com

Abstract

This paper is a quickstart for anyone aims to setup a working Signal Server.

What Is Signal

Signal is an encrypted instant messaging and voice calling application for Android. It uses the Internet to send one-to-one and group messages, which can include images and video messages, and make one-to-one voice calls. Signal uses standard phone numbers as identifiers and end-to-end encryption to secure all communications to other Signal users.