Skip to content

Instantly share code, notes, and snippets.

@jamztang
jamztang / CSLoopingAnimationView.h
Created April 16, 2014 14:41
Use Canvas to loop animation forever (hacky way)
#import <UIKit/UIKit.h>
#import "CSAnimation.h"
#import "CSAnimationView.h"
@interface CSLoopingAnimationView : CSAnimationView
@end
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
[[NSUserDefaults standardUserDefaults] setObject:version
forKey:@"version_preference"];
NSString *build = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
[[NSUserDefaults standardUserDefaults] setObject:build
forKey:@"build_preference"];
NSString *githash = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"GITHash"];
[[NSUserDefaults standardUserDefaults] setObject:githash
@jamztang
jamztang / keypath.h
Created October 30, 2014 11:14
A simple @keypath marco
// usage: @keypath(arg)
// like how you use @selector(arg)
// For a full implementation, checkout https://github.com/jspahrsummers/libextobjc
#define keypath(PATH) \
(((\
NSStringFromSelector(@selector(PATH))\
), # PATH))
@jamztang
jamztang / LoggingTextView.swift
Last active August 29, 2015 14:15
Display logs with func logln()
// The MIT License (MIT)
//
// Copyright (c) 2015 James Tang (j@jamztang.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@jamztang
jamztang / README.md
Created September 2, 2011 08:25
Adding fadeout effect to any -[UIViews removeFromSuperview]

Sometimes it’s not that please for a user to see an UI component disappearing suddenly. You’d then consider adding some transition effects, and here’s a little code snippet in the UIView+JTRemoveAnimated category for how you can get a fade out effect on view removal.

So from now on, you just needed to do this to fade out any UIViews

[myView removeFromSuperviewAnimated]

@jamztang
jamztang / rsync_xcode_clean
Created September 2, 2011 08:11
Using rsync to extract code out of .git
rsync_xcode_clean () { rsync -av $1 --exclude "DerivedData" --exclude "build" --exclude ".git" $2; }
@jamztang
jamztang / symbolizecrashlog
Created September 15, 2011 12:22
symbolizecrashlog fixed script for iOS apps. (Fixed regex for both .crash and copy/pasted crash logs)
#!/bin/bash
AWK_SCRIPT=/tmp/symbolizecrashlog_$$.awk
SH_SCRIPT=/tmp/symbolizecrashlog_$$.sh
if [[ $# < 2 ]]
then
echo "Usage: $0 [ -arch <arch> ] symbol-file [ crash.log, ... ]"
exit 1
fi
@jamztang
jamztang / makeIpaFromApp
Created September 15, 2011 12:26
Script that archive an .app to .ipa for iOS developement builds - makeIpaFromApp
#!/bin/bash
#init
#function pause() {
#read -p "$*"
#}
payloadDIR="Payload"
#if [ -d $payloadDIR ]
@jamztang
jamztang / .gitignore
Created September 16, 2011 11:31
.gitignore template for iOS projects
.DS_Store
.svn
build
DerivedData
*.xcodeproj/*.mode1v3
*.xcodeproj/*.pbxuser
*.xcodeproj/project.xcworkspace/*
*.xcodeproj/xcuserdata/*
@jamztang
jamztang / UIImage+JTImageDecode.h
Created October 2, 2011 05:40
Force UIImage to decompress
//
// UIImage+JTImageDecode.h
//
// Created by james on 9/28/11.
// http://ioscodesnippet.tumblr.com
//
@interface UIImage (JTImageDecode)
+ (UIImage *)decodedImageWithImage:(UIImage *)image;
@end