Skip to content

Instantly share code, notes, and snippets.

View fantattitude's full-sized avatar
🎯
Focusing

Vivien Leroy fantattitude

🎯
Focusing
View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Carlos Melegrito (mlgrto.com)</string>
<key>name</key>
<string>Facebook Dark</string>
<key>semanticClass</key>
<string>theme.dark.base16_solarized_dark</string>
@DeFrenZ
DeFrenZ / FSLVExample.swift
Created November 17, 2014 11:54
FiniteStateLayoutView
//
// FSLVExample.swift
// FSLVExample
//
// Created by Davide De Franceschi on 16/11/14.
// Copyright (c) 2014 Davide De Franceschi. All rights reserved.
//
import UIKit
@nicklockwood
nicklockwood / Deprecated.md
Last active March 28, 2022 08:16
Writing Objective-C framework code that works on multiple OS versions AND can be compiled using multiple SDK versions without warnings can be a PITA. Here's my approach:

Suppose we want to add support for a new iOS 8 API in our framework that replaces an older iOS 7 API. There are a few problems we might face:

  1. The new API will crash if we call it on iOS 7
  2. The new API won't compile if we build it using the iOS 7 SDK
  3. The old API will raise a deprecation warning if built with a deployment target of iOS 8 and up

These three problems require three different technical solutions:

  1. We can avoid calling the new API on an old OS version by using runtime detection (e.g. respondsToSelector:)
  2. We can avoid compiling new APIs on old SDKs using the __IPHONE_OS_VERSION_MAX_ALLOWED macro
@MrCloud
MrCloud / Swift-Singleton-Snippet
Last active August 29, 2015 14:02
An Xcode Snippet for Singleton implementation in Swift
class <#ClassName#> {
class func sharedInstance() -> <#ClassName#> {
struct Static<#ClassName#> {
static let sharedInstance = <#ClassName#>()
}
return <#ClassName#>.sharedInstance
}
}
/* You might ask why there is no GCD related calls here with the obvious dispatch_once/token pair here.
@mattdonnelly
mattdonnelly / UIImage+vImageScaling.h
Last active November 8, 2019 17:20
An Objective-C UIImage category for better resizing using vImage
//
// UIImage+vImageScaling.h
// UIImage+vImageScaling
//
// Created by Matt Donnelly on 03/07/2013.
// Copyright (c) 2013 Matt Donnelly. All rights reserved.
//
#import <UIKit/UIKit.h>
@willurd
willurd / web-servers.md
Last active May 7, 2024 14:57
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@fantattitude
fantattitude / gist:4353648
Created December 21, 2012 15:57
UIView to UIImage category method by @Dimillian
+ (UIImage*)captureView:(UIView *)viewToCapture {
if([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
UIGraphicsBeginImageContextWithOptions(viewToCapture.bounds.size, NO, [UIScreen mainScreen].scale);
else
UIGraphicsBeginImageContext(viewToCapture.bounds.size);
[viewToCapture.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
@Gi-lo
Gi-lo / gist:4279932
Created December 13, 2012 21:11
Easily create GET NSURLs in Objective-C. (Used in https://github.com/Gi-lo/GCXHTTPOperation )
- (NSURL *)URLWithString:(NSString *)string andQueryValuesForKeys:(NSString *)value, ... {
if (!value) {
return [NSURL URLWithString:string];
}
NSMutableString *queryString = [NSMutableString string];
NSString *argument = nil;
NSUInteger argumentCount = 0;
va_list argumentList;
@datagrok
datagrok / git-branch-simplify.md
Last active April 16, 2024 17:26
How to simplify the graph produced by git log --graph

Ideas for improvements to git log --graph

I will maybe someday get around to dusting off my C and making these changes myself unless someone else does it first.

Make the graph for --topo-order less wiggly

Imagine a long-running development branch periodically merges from master. The git log --graph --all --topo-order is not as simple as it could be, as of git version 1.7.10.4.

It doesn't seem like a big deal in this example, but when you're trying to follow the history trails in ASCII and you've got several different branches displayed at once, it gets difficult quickly.

@fantattitude
fantattitude / gist:3403116
Created August 20, 2012 10:47
What's the difference between a good and a bad place to work ?

Me:

“Do you know the difference between a good place to work and a bad place to work?”

Steve:

“Umm, I think so.”

Me:

“What is the difference?”

Steve: