Skip to content

Instantly share code, notes, and snippets.

View frederik-jacques's full-sized avatar

Frederik Jacques frederik-jacques

View GitHub Profile
frederik-jacques / Boolean+extensions.swift
Created September 13, 2017 20:23
Easily map to a value based on the value of a Boolean
import Foundation
extension Bool {
/// Convenience method to map the value of a Boolean to a specific Type.
/// - Parameters:
/// - ifTrue: The result when the Boolean is true
/// - ifFalse: The result when the Boolean is false
/// - Returns: Returns the result of a specific Type
Version one
-> Expected result
String shows Devine rocks, background set to purple for the whole string
Background set to red for the word 'rocks'
-> Got expected result (
frederik-jacques / Enumerate available font names
Created March 10, 2015 10:30
A Swift function to loop over all available font families and print out the different font names. You need this if you want to use custom fonts in your app and pass in the name for the UIFont class.
func enumerateFonts(){
for fontFamily in UIFont.familyNames() {
println("Font family name = \(fontFamily as String)");
for fontName in UIFont.fontNamesForFamilyName(fontFamily as String) {
println("- Font name = \(fontName)");
frederik-jacques / objc_enumerate_fonts
Created March 13, 2013 09:55
Enumerate all fonts on your IOS device with this convenience method. Handy to find the name for your custom font!
- (void)enumerateFonts {
NSLog(@"--Start enumerating font--");
for (NSString *fontFamilyStrings in [UIFont familyNames]) {
NSLog(@"Font family: %@", fontFamilyStrings);
for (NSString *fontStrings in [UIFont fontNamesForFamilyName:fontFamilyStrings]) {
NSLog(@"-- Font: %@", fontStrings);
NSLog(@"--End enumerating font--");
frederik-jacques / belgian_cities_sql_dump
Last active December 11, 2015 22:18
SQL dump of all the Belgian cities linked to their provinces. Thanks to @anthonyvanoyen and @jverdeyen for pointing me to some start files.
SET time_zone = "+00:00";
-- Table structure for table `cities`
CREATE TABLE `cities` (
`province_id` int(11) NOT NULL,