Skip to content

Instantly share code, notes, and snippets.

@veritech
veritech / CALayer.m
Created April 12, 2011 12:24
Using CAKeyFrameAnimation to animate images in a CALayer
//Create the layer
layer = [CALayer layer];
//Configure the animation
animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
[animation setCalculationMode:kCAAnimationDiscrete];
[animation setDuration:2.0f];
[animation setRepeatCount:HUGE_VALF];
@mike3k
mike3k / chk_enrypt.c
Created June 19, 2012 20:15
Check for encrypted iOS binary
#import <dlfcn.h>
#import <mach-o/loader.h>
/* The encryption info struct and constants are missing from the iPhoneSimulator SDK, but not from the iPhoneOS or
* Mac OS X SDKs. Since one doesn't ever ship a Simulator binary, we'll just provide the definitions here. */
#if TARGET_IPHONE_SIMULATOR && !defined(LC_ENCRYPTION_INFO)
#define LC_ENCRYPTION_INFO 0x21
struct encryption_info_command {
@dhoerl
dhoerl / AppDelegate(category).m
Created July 26, 2012 23:19
Keychain Wrapper for dictionary (NSData) not a single NSString
static NSString *kcIdentifier = @"MyApp";
@implementation LTAppDelegate (KeyChain)
- (void)keychainInit
{
self.keychainDict = [NSMutableDictionary dictionaryWithCapacity:7];
KeychainItemWrapper *item = [[KeychainItemWrapper alloc] initWithIdentifier:kcIdentifier accessGroup:nil];
[self.keychainDict setObject:@"" forKey:kcEmailAddress];
@zetachang
zetachang / gist:4111314
Created November 19, 2012 15:37
Instruction on adding a Acknowledgements Settings.bundle
  • To add Settings.bundle in Xcode. Command N and in Resource, choose Settings Bundle .
  • Open Root.plist in source code, paste the code below to replace it,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>PreferenceSpecifiers</key>
	
@SQiShER
SQiShER / URLConnection.h
Last active July 16, 2020 10:51
Here is my solution for a better synchronous NSURLConnection. Although asynchronous NSURLConnections are usually a good way to go, sometimes there is just no way around waiting (and blocking) until a request finished. NSURLConnection offers a method to perform synchronous requests, but it is far from perfect and has some serious flaws. In my cas…
#import <Foundation/Foundation.h>
@interface URLConnection : NSObject <NSURLConnectionDataDelegate, NSURLConnectionDelegate>
+ (NSData *)sendSynchronousRequest:(NSURLRequest *)request
returningResponse:(NSURLResponse **)response
error:(NSError **)error;
@end
@luca-bernardi
luca-bernardi / AVAsset+VideoOrientation.h
Created February 23, 2013 18:12
Find the video orientation of an AVAsset. (Useful if you need to send the video to a remote server)
//
// AVAsset+VideoOrientation.h
//
// Created by Luca Bernardi on 19/09/12.
// Copyright (c) 2012 Luca Bernardi. All rights reserved.
//
#import <AVFoundation/AVFoundation.h>
typedef enum {
LBVideoOrientationUp, //Device starts recording in Portrait
@Valthoron
Valthoron / xcode-build-bump.sh
Last active December 9, 2022 10:22 — forked from sekati/xcode-build-bump.sh
Set a timestamp as the build number when an Xcode project is compiled.
# xcode-build-timestamp.sh
# @desc Set a timestamp as the build number when the project is compiled.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Target dependencies"
buildNumber=$(date +%Y%m%d%H%M)
@Shilo
Shilo / NSString+XML.h
Last active December 22, 2015 03:19
Customizable string XML parser for NSString, NSMutableString, NSAttributedString, and NSMutableAttributedString.
//
// NSString+XML.h
// Customizable string XML parser for NSString, NSMutableString, NSAttributedString, and NSMutableAttributedString.
//
// Created by Shilo White on 8/31/13.
// Copyright (c) 2013 XIDA Design & Technik. All rights reserved.
//
#import <Foundation/Foundation.h>
@niksumeiko
niksumeiko / git.migrate
Last active June 28, 2024 21:01
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@paztek
paztek / AppDelegate.m
Last active June 11, 2019 20:54
Allows videos to rotate in landscape when displayed in a portrait only iOS app
#import "AppDelegate.h"
#import <MediaPlayer/MediaPlayer.h>
@implementation AppDelegate
{
BOOL _isFullScreen;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{