Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# Script for managing build and version numbers using git and agvtool.
# Change log:
# v1.0 18-Jul-11 First public release.
# v1.1 29-Sep-12 Launch git, agvtool via xcrun.
version() {
@doskoi
doskoi / gist:4022798
Created November 6, 2012 05:38
UIWebview remove shadow
-(UIScrollView *)defaultScrollView
{
if (_defaultScrollView == nil) {
UIScrollView *scrollView = nil;
for (UIView *subview in [self subviews]) {
if ([subview isKindOfClass:[UIScrollView class]]) {
scrollView = (UIScrollView *)subview;
}
}
if (scrollView == nil) {
@doskoi
doskoi / gist:3081328
Created July 10, 2012 05:31
Getting image from UIWebView
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
NSLog(@"TAPPED");
//Touch gestures below top bar should not make the page turn.
//EDITED Check for only Tap here instead.
if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) {
CGPoint touchPoint = [touch locationInView:self.view];
if(self.interfaceOrientation==UIInterfaceOrientationPortrait||self.interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) {
NSString *imgURL = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).src", touchPoint.x, touchPoint.y];
NSString *urlToSave = [webV stringByEvaluatingJavaScriptFromString:imgURL];
# xcode specific
build/*
*.pbxuser
*.mode1v3
*.mode2v3
*.perspective
*.perspectivev3
# xcode 4
xcuserdata
project.xcworkspace
*.pbxproj -crlf -diff -merge
@doskoi
doskoi / gist:1653073
Created January 21, 2012 15:30
Device Detection
#import <sys/utsname.h>
enum {
MODEL_IPHONE_SIMULATOR,
MODEL_IPOD_TOUCH,
MODEL_IPHONE,
MODEL_IPHONE_3G
};
@interface DeviceDetection : NSObject
@doskoi
doskoi / gist:1653064
Created January 21, 2012 15:26
Convert an Image (UIImage) to Grayscale
- (UIImage *)convertImageToGrayScale:(UIImage *)image
{
// Create image rectangle with current image width/height
CGRect imageRect = CGRectMake(0, 0, image.size.width, image.size.height);
// Grayscale color space
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
// Create bitmap content with current image size and grayscale colorspace
CGContextRef context = CGBitmapContextCreate(nil, image.size.width, image.size.height, 8, 0, colorSpace, kCGImageAlphaNone);
@doskoi
doskoi / gist:1653030
Created January 21, 2012 15:12
Turn FIXME, TODO, and !!! comments into compiler warnings within xcode
KEYWORDS="TODO|FIXME|\?\?\?:|\!\!\!:"
find ${SRCROOT} \( -name "*.h" -or -name "*.m" \) -print0 | \
xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | \
perl -p -e "s/($KEYWORDS)/ warning: \$1/"
Here are some regex script use in vim to help you translate objc code to cpp version.It is not perfect since it just could translate nearly 80% code correctly.
how to use it :
1.open mac terminal
2.run vim open the objec-code file
3.copy the regex below
4.click the edit->paste on the terminal menu
5.prees enter key
6.repeat step 4 - 5 seviral times
7.done
@doskoi
doskoi / gist:1069240
Created July 7, 2011 10:12
Unity3D GUI Resolution
function OnGUI() {
var screenScale: float = Screen.width / 480.0;
var scaledMatrix: Matrix4x4 = Matrix4x4.identity.Scale(Vector3(screenScale,screenScale,screenScale));
GUI.matrix = scaledMatrix;
// then do the rest of your GUI as per normal, using the 480x320 screen size you had for your standard res iPhone app
}