Skip to content

Instantly share code, notes, and snippets.

View Abeansits's full-sized avatar
🙃
...

Sebastian Abeansits

🙃
...
View GitHub Profile
#!/bin/sh
#
# Automatically adds branch name and branch description to every commit message.
#
NAME=$(git branch | grep '*' | sed 's/* //')
DESCRIPTION=$(git config branch."$NAME".description)
TEXT=$(cat "$1" | sed '/^#.*/d')
if [ -n "$TEXT" ]
then
echo "[$NAME] $TEXT" > "$1"
@Abeansits
Abeansits / CallbackDictionary.swift
Last active May 25, 2017 18:38
A thread safe callback dictionary
import Foundation
/// A thread-safe container for mapping a String key to a `CallbackBlock`. A callback-block can be invoked individually or all at once.
public struct CallbackDictionary<ResultType> {
// MARK: - Initializing
public init() {}
// MARK: - Public Interface
protocol FirstDependency {}
protocol SecondDependency {}
protocol ThirdDependency {}
protocol HasFirstDependency {
var first: FirstDependency { get }
}
protocol HasSecondDependency {
var second: SecondDependency { get }
@Abeansits
Abeansits / UIScrollView+Extensions.h
Created January 8, 2014 14:27
A category on UIScrollView for detecting when content has scrolled to top or bottom.
//
// UIScrollView+Extensions.h
//
//
@interface UIScrollView (Extensions)
/// Returns true if the content has been scrolled all the way to the top (by pulling the content up).
- (BOOL)isScrolledToTop;
@Abeansits
Abeansits / NSString+Extensions.h
Created June 24, 2013 07:31
A utility box for NSStrings. Converts to: SHA1, NSNumber. Test for being empty. Contains substrings and replace substrings from NSDictionary.
#import <Foundation/Foundation.h>
@interface NSString (Extensions)
+ (NSString *)stringToSha1:(NSString *)str;
- (NSNumber*)stringToNSNumber;
- (BOOL)isEmpty;
- (BOOL)stringContainsSubString:(NSString *)subString;
- (NSString *)stringByReplacingStringsFromDictionary:(NSDictionary *)dict;
@Abeansits
Abeansits / gist:5487191
Created April 30, 2013 07:40
Printing character per character to find those hard to see invisible characters that may mess up your JSON-parsing or similar.
const unsigned char *ptr = [data bytes];
for(NSUInteger i=0; i<[data length]; ++i) {
unsigned char c = *ptr++;
NSLog(@"char=%c hex=%x", c, c);
}
@Abeansits
Abeansits / project.pbxproj
Created September 25, 2012 09:57
Possibly broken project file.
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
0E27D737133B88F700953527 /* CDataScanner.m in Sources */ = {isa = PBXBuildFile; fileRef = 0E27D722133B88F700953527 /* CDataScanner.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };