Skip to content

Instantly share code, notes, and snippets.

fabb

Block or report user

Report or block fabb

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
View gource-submodules.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Generates Gource config file from git submodules, starts Gource.
# Place to /usr/local/bin and run at the main repository root.
#
# (c) 2010 Mikael Lammentausta
# License is the same as Gource (GPLv3)
import os
import re
View UIImage+Colorize.swift
import UIKit
extension UIImage {
// colorize image with given tint color
// this is similar to Photoshop's "Color" layer blend mode
// this is perfect for non-greyscale source images, and images that have both highlights and shadows that should be preserved
// white will stay white and black will stay black as the lightness of the image is preserved
func tint(tintColor: UIColor) -> UIImage {
View TheAbyss.h
// TheAbyss.h
+ (NSString *)greetingMessageFromTheOtherworld;
// TheAbyss.m
+ (NSString *)greetingMessageFromTheOtherworld {
return nil;
}
// LonesomeWanderer.swift
TheAbyss.greetingMessageFromTheOtherworld().isEmpty
@fabb
fabb / archive_ipa.sh
Created Nov 1, 2014
Script to archive an ipa from commandline - depends on xctool
View archive_ipa.sh
#!/bin/bash
set -x
cd ${0%/*}/..
# codesigning and choosing of provisioning profile is configured via project settings and is dependent of build config
: ${BUILD_NUMBER:?"Need to set BUILD_NUMBER"}
WORKSPACE=<yourworkspace>.xcworkspace
@fabb
fabb / gist:5908388
Created Jul 2, 2013
format current NSDate as ISO8601 string despite user's Calendar or 24-Hour-Format setting
View gist:5908388
- (NSString *)currentGregorianISO8601Date {
NSDate *requestDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
// WORKAROUND http://openradar.appspot.com/radar?id=1110403
[dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"US"]];
// translate to Gregorian calendar if other calendar is selected
View SongPoll3.swift
import Foundation
struct Song {
var title: String
var length: Float
mutating func addAdvertisement() {
self.title += " plus commercial"
self.length += 10
}
View SongPoll4.swift
import Foundation
struct Song {
let title: String
let length: Float
func withAddedAdvertisement() -> Song {
return Song(title: self.title + " plus commercial", length: self.length + 10)
}
}
@fabb
fabb / gist:5019653
Created Feb 23, 2013
Issue #4 in PySCXML: transition also exits & enters again unaffected states
View gist:5019653
import time
from scxml.pyscxml import StateMachine
import logging
logging.basicConfig(level=logging.NOTSET) # show detailed debug info
xml = '''
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0">
<state id="main">
<onentry>
@fabb
fabb / gist:5014867
Last active Dec 14, 2015
Seemingly buggy behavior with PySCXML: the second event "f" is not received in most executions
View gist:5014867
import time
from scxml.pyscxml import StateMachine
import logging
logging.basicConfig(level=logging.NOTSET) # show detailed debug info
xml = '''
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" datamodel="python" initial="S1">
<state id="S1">
<onentry>
View MFetchedResultsController.swift
//some time, frc section may be need section offset
@objc public protocol MFetchedResultsControllerOffsetSectionDelegate{
func offsetSection() -> Int
}
class MFetchedResultsController: NSFetchedResultsController, NSFetchedResultsControllerDelegate {
weak var viewController: UIViewController? //UITableViewController UICollectionViewController
weak var scrollView: UIScrollView? //TableView CollectionView
weak var offsetSectionDelegate: MFetchedResultsControllerOffsetSectionDelegate?
You can’t perform that action at this time.