Skip to content

Instantly share code, notes, and snippets.

Gianni Gianino giannigdev

  • Indie Developer
  • Turin, Italy
Block or report user

Report or block giannigdev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@michaelochs
michaelochs / NSFormattingContextDynamic.m
Created Dec 13, 2016
`NSFormattingContextDynamic` makes a formatter return string proxies that change based on where you but them inside a format string.
View NSFormattingContextDynamic.m
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"
View gist:82a32312af663ea59782
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
View homogeneous.swift
import Foundation
extension String {
var isHomogeneous: Bool {
if lengthOfBytesUsingEncoding(NSUTF8StringEncoding) == 0 {
return true
}
var homogeneous = true
var character: NSString?
View Silly dice roller
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 Dec 3, 2018
Our set of warnings in PSPDFKit
View gist:d76549ec262430354e7c
//
// 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:
View UIView bounds difference.md

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:

<CABasicAnimation:0x7fdefbd1dbf0; 
View FizzBuzz.swift
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 Aug 8, 2014
Create empty Swift playground files
View gist:340c240c50aed6c71a1e
#! /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 Aug 8, 2014
Learn the LLVM C++ API by example.
View README.markdown

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
You can’t perform that action at this time.