Skip to content

Instantly share code, notes, and snippets.

View giannigdev's full-sized avatar

Gianni giannigdev

View GitHub Profile
@michaelochs
michaelochs / NSFormattingContextDynamic.m
Created December 13, 2016 15:37
`NSFormattingContextDynamic` makes a formatter return string proxies that change based on where you but them inside a format string.
NSDate *date = [NSDate new];
NSDateFormatter *dateFormatter = [NSDateFormatter new];
dateFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"nl_NL"];
dateFormatter.dateStyle = NSDateFormatterFullStyle;
dateFormatter.formattingContext = NSFormattingContextDynamic; // this is the important setting
NSString *dateString = [dateFormatter stringFromDate:date];
NSString *s1 = [NSString stringWithFormat:@"Foo %@", dateString]; // "Foo dinsdag 13 december 2016"
@modocache
modocache / gist:82a32312af663ea59782
Created September 27, 2015 17:00
Xcode Stack Trace
Process: Xcode [59837]
Path: /Applications/Xcode-beta.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 7.1 (9069)
Build Info: IDEFrameworks-9069000000000000~10
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Xcode [59837]
User ID: 1199935289
import Foundation
extension String {
var isHomogeneous: Bool {
if lengthOfBytesUsingEncoding(NSUTF8StringEncoding) == 0 {
return true
}
var homogeneous = true
var character: NSString?
@JaviLorbada
JaviLorbada / FRP iOS Learning resources.md
Last active April 8, 2024 18:07
The best FRP iOS resources.

Videos

anonymous
anonymous / Silly dice roller
Created September 24, 2014 06:52
import Foundation
struct Dice : SequenceType {
typealias Generator = GeneratorOf<Int>
let dice:[Int]
init (rolls:Int, sides:Int) {
dice = Array(count:rolls, repeatedValue:sides)
}
func roll() -> Int {
return dice.map { Int(arc4random_uniform(UInt32($0 - 1)) + 1) }
@steipete
steipete / gist:d76549ec262430354e7c
Last active December 3, 2018 23:56
Our set of warnings in PSPDFKit
//
// Warnings.xcconfig
//
// The list of warnings we (don’t) use, and the reasons why.
//
// :MARK: Warnings in use:
// :MARK: -everything
// We want the best possible diagnostics, so we simply enable everything that exists, and then opt–out of what doesn’t make sense for us.
//
// :MARK: - Warnings not to be promoted:

The UIView animation API results in different CAAnimations being added to the layer on iOS 7 and 8. Changing the bounds of a view like this:

[UIView animateWithDuration:0.3 
                 animations:^{
    self.myView.bounds = CGRectMake(0, 0, 100, 100); // was (0,0) (200, 200)
}];

will result in one animation for the bounds key path being added to the backing layer if you are running iOS 7:

enum FizzBuzz {
case fizz
case buzz
case fizzBuzz
case number(Int)
init(rawValue: Int) {
switch (rawValue % 3, rawValue % 5) {
case (0, 0): self = .fizzBuzz
case (0, _): self = .fizz
@marcboquet
marcboquet / gist:340c240c50aed6c71a1e
Created August 8, 2014 15:37
Create empty Swift playground files
#! /usr/bin/ruby
require 'pathname'
platform = "iphonesimulator" # or "macosx"
contents_xcplayground = <<XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='1.0' sdk='#{platform}'>
<sections>
<code source-file-name='section-1.swift'/>
</sections>
@alloy
alloy / README.markdown
Created August 8, 2014 09:56
Learn the LLVM C++ API by example.

The easiest way to start using the LLVM C++ API by example is to have LLVM generate the API usage for a given code sample. In this example it will emit the code required to rebuild the test.c sample by using LLVM:

$ clang -c -emit-llvm test.c -o test.ll
$ llc -march=cpp test.ll -o test.cpp