Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am mundstein on github.
  • I am mundi (https://keybase.io/mundi) on keybase.
  • I have a public key ASA5iSoQ2q-mFS4zgKoJenXyybmb4VZ-y3T1P1xYEi4nBAo

To claim this, I am signing this object:

@mundstein
mundstein / Prefix.pch
Created August 10, 2013 10:01
Macros to check iOS / Mac os versions in Objective-C
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
@mundstein
mundstein / Passwd.vb
Created June 10, 2013 09:41
Excel password breaker
Sub PasswordBreaker()
'Breaks worksheet password protection.
Dim i As Integer, j As Integer, k As Integer
Dim l As Integer, m As Integer, n As Integer
Dim i1 As Integer, i2 As Integer, i3 As Integer
Dim i4 As Integer, i5 As Integer, i6 As Integer
On Error Resume Next
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
@mundstein
mundstein / Circle.m
Created March 21, 2013 14:25
UIView for deleting icons: little x in a circle added to the top left.
// CancelView.m
//
// Created by Sascha Mundstein on 3/21/13.
// Copyright (c) 2013 Erica Sadun. All rights reserved.
//
@interface CancelView : UIView
@end
@implementation CancelView
@mundstein
mundstein / quiver.m
Last active December 15, 2015 03:49
View Quiviring for iOS, like in Springboard. Ideal for collection views before deleting.
// INSERT CELL ANIMATION SNIPPET HERE
- (void)startQuivering
{
CABasicAnimation *quiverAnim = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
float startAngle = (-2) * M_PI/180.0;
float stopAngle = -startAngle;
quiverAnim.fromValue = [NSNumber numberWithFloat:startAngle];
quiverAnim.toValue = [NSNumber numberWithFloat:3 * stopAngle];
quiverAnim.autoreverses = YES;
quiverAnim.duration = 0.2;
@mundstein
mundstein / UIImage+Masking.m
Created October 29, 2012 11:34
Great simple masking image routine for core graphics
- (UIImage*) maskImage:(UIImage *)im withMask:(UIImage *)maskImage {
CGImageRef maskRef = maskImage.CGImage;
CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef),
CGImageGetHeight(maskRef),
CGImageGetBitsPerComponent(maskRef),
CGImageGetBitsPerPixel(maskRef),
CGImageGetBytesPerRow(maskRef),
CGImageGetDataProvider(maskRef), NULL, false);
@mundstein
mundstein / Localize.m
Created August 27, 2012 21:01
Easy way to localize independent of user setting
// The main localization class that does the hard work
-(NSString *) localized:(NSString *) key
{
// langCode should be set as a global variable somewhere
NSString *path = [[NSBundle mainBundle] pathForResource:langCode ofType:@"lproj"];
NSBundle* languageBundle = [NSBundle bundleWithPath:path];
return [languageBundle localizedStringForKey:key value:@"" table:nil];;
}
@mundstein
mundstein / ShadowButton.h
Created June 23, 2012 11:54
Button with drop shadow for iPhone which also animates down when pressed.
//
// ShadowButton.h
#import <Foundation/Foundation.h>
@interface ShadowButton : UIButton {
}
@end
@mundstein
mundstein / shadow.m
Created May 10, 2012 12:47
Create a fancy shadow^
/*
* Create a fancy shadow around the frontView.
*
* Note: UIBezierPath needed because shadows are evil. If you don't use the path, you might not
* not notice a difference at first, but the keen eye will (even on an iPhone 4S) observe that
* the interface rotation _WILL_ lag slightly and feel less fluid than with the path.
*/
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:self.frontView.bounds];
self.frontView.layer.masksToBounds = NO;
self.frontView.layer.shadowColor = [UIColor blackColor].CGColor;
@mundstein
mundstein / NSObject+Block.m
Created April 22, 2012 19:19
Extend NSObject to perform block after delay
@implementation NSObject (PerformBlockAfterDelay)
- (void)performBlock:(void (^)(void))block
afterDelay:(NSTimeInterval)delay
{
block = [[block copy] autorelease];
[self performSelector:@selector(fireBlockAfterDelay:)
withObject:block
afterDelay:delay];
}