Skip to content

Instantly share code, notes, and snippets.

@hfossli
hfossli / gist:5130975
Last active July 21, 2017 10:48
Tests
CGPoint CGPointApplyCATransform3D(CGPoint point, CATransform3D transform, CGPoint anchorPoint, CATransform3D parentSublayerTransform)
{
static CALayer *sublayer, *layer;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sublayer = [CALayer layer];
layer = [CALayer layer];
[layer addSublayer:sublayer];
});
@hfossli
hfossli / ffmpeg_split.sh
Last active December 27, 2020 21:47
A bash / shell script for splitting videos / movies into several / multiple files using ffmpeg
#!/bin/bash
# Created by Håvard Fossli <hfossli@gmail.com> in 2013
# Derived from Alexis Bezverkhyy <alexis@grapsus.net> in 2011
# This is free and unencumbered software released into the public domain.
# For more information, please refer to <http://unlicense.org/>
#
# Description
# A bash script for splitting videos into several files using ffmpeg.
#
@hfossli
hfossli / ffmpeg_sox_reverse.sh
Last active May 12, 2022 07:32
A bash script for reversing videos using ffmpeg and sox.
#!/bin/bash
# Created by Håvard Fossli <hfossli@gmail.com> in 2013
# This is free and unencumbered software released into the public domain.
# For more information, please refer to <http://unlicense.org/>
#
# Description
# A bash script for reversing videos using ffmpeg and sox.
#
# Keywords
@hfossli
hfossli / xcode-git-commit-hash-cfbundleversion.rb
Created August 2, 2013 12:27
Run script for Xcode to run after build / archive - updates CFBundleVersion in Info.plist file with short git commit hash
#!/usr/bin/ruby
# xcode-git-commit-hash-cfbundleversion.rb
# Run script for Xcode to run after build / archive
# Updates CFBundleVersion in Info.plist file with short git commit hash
#
# This is based on
# http://github.com/guicocoa/xcode-git-cfbundleversion/
# http://github.com/digdog/xcode-git-cfbundleversion/
# http://github.com/jsallis/xcode-git-versioner
# http://github.com/juretta/iphone-project-tools/tree/v1.0.3
@hfossli
hfossli / IVYApplication.h
Created September 30, 2013 18:09
UIApplication does not send notificaiton wether status bar is hidden or not. This class does!
#import <UIKit/UIKit.h>
extern NSString * const UIApplicationDidHideStatusBarNotification;
@interface IVYApplication : UIApplication
@end
@hfossli
hfossli / UIScrollView+ScrollsToTop.h
Last active December 27, 2016 22:17
A simple way to make sure there is only one scrollview which is able to scroll to top at a time
#import <UIKit/UIKit.h>
@interface UIScrollView (ScrollsToTop)
+ (void)forceNewViewsDefaultValueForScrollsToTop;
+ (void)makeOnlyThisScrollViewScrollToTopOnStatusBarTap:(UIScrollView *)scrollView;
- (void)makeOnlyThisScrollViewScrollToTopOnStatusBarTap;
@end
@hfossli
hfossli / main.m
Last active December 25, 2015 20:59
Regex vs componentsSeparatedByCharactersInSet
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
NSUInteger iterations = 1000000;
{ // Regex
NSTimeInterval timeStart = CFAbsoluteTimeGetCurrent();
NSString *result = nil;
@hfossli
hfossli / gist:7234623
Last active April 19, 2024 10:09
KVO on a views geometry
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 300, 200)];
view.backgroundColor = [UIColor blueColor];
[self.view addSubview:view];
[view addObserver:self forKeyPath:@"frame" options:0 context:NULL];
@hfossli
hfossli / gist:7562257
Last active June 27, 2018 04:56
A bash script for fetching all branches and tags of a git project as snapshots into separate folders
#!/bin/bash
# Created by Håvard Fossli <hfossli@gmail.com> in 2013
# This is free and unencumbered software released into the public domain.
# For more information, please refer to <http://unlicense.org/>
#
# Description
# A bash script for fetching all branches and tags of a git project as snapshots into separate folders
#
# Keywords
@hfossli
hfossli / DataObject.h
Last active December 31, 2015 20:39
Private, protected and public properties in objective-c
@interface DataObject : NSObject
// public properties
@end