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
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 (http://cl.ly/image/2Q1u0D1B0u0V)
*/
@frederik-jacques
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
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
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 SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Table structure for table `cities`
--
CREATE TABLE `cities` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`province_id` int(11) NOT NULL,