Skip to content

Instantly share code, notes, and snippets.

View Azuritul's full-sized avatar

Wu Azuritul

  • Azuritul Studio
  • Tokyo
View GitHub Profile
@Azuritul
Azuritul / gist:1113579
Created July 29, 2011 10:25
使用usedEncoding及big5 encoding轉換
NSStringEncoding usedEncoding;
NSError * err;
NSString * k = [NSString stringWithContentsOfFile:path usedEncoding:&usedEncoding error:&err];
if (err) {
NSStringEncoding big5 = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingBig5_HKSCS_1999);
k = [NSString stringWithContentsOfFile:path encoding:big5 error:&err];
}
@Azuritul
Azuritul / gist:1120035
Created August 2, 2011 11:39
Using UIPopoverController
/* Using popover to present service list */
UIPopoverController * popover = [[UIPopoverController alloc] initWithContentViewController:aController];
popover.popoverContentSize = CGSizeMake(320.0, 400.0);
popover.delegate = self;
[aController release];
[popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
@Azuritul
Azuritul / .gitignore
Last active June 29, 2024 13:15
General gitignore file sample
# IDEA Ignores #
################
*.iml
*.ipr
*.iws
.idea/
out/
local.properties
# Generic Android ignores #
@Azuritul
Azuritul / Check UIViewController Visibility
Created August 31, 2011 08:54
Check if a view controller is visible
/*
* Check http://stackoverflow.com/questions/2777438/how-to-tell-if-uiviewcontrollers-view-is-visible
* to see the discussions.
* If the container is a UINavigationController,
* we can use the visibleViewController property
* to check the visibility.
*/
navigationController visibleViewController == self
/* Or, we can add a category to UIViewController
@Azuritul
Azuritul / gist:1735379
Created February 4, 2012 04:40
Walking directory
/*
* Excerpt from :
* http://rosettacode.org/wiki/Walk_a_directory/Recursively#Objective-C
*/
NSString *dir = NSHomeDirectory();
NSDirectoryEnumerator *de = [[NSFileManager defaultManager] enumeratorAtPath:dir];
NSString *file;
while ((file = [de nextObject]))
if ([[file pathExtension] isEqualToString:@"mp3"])
@Azuritul
Azuritul / GetDate
Created January 22, 2014 09:50
Demonstrate how to get date in bash shell
TODAY=`date +%Y%m%d`
YESTERDAY=`TZ=GMT+24 date +%Y%m%d`
echo $TODAY
echo $YESTERDAY
@Azuritul
Azuritul / gist:8332ae429aefd9259edb
Created September 3, 2014 08:32
Mac iTerm color
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=dxfxcxdxbxegedabagacad
@Azuritul
Azuritul / gist:191372033608ab86fecb
Created October 4, 2014 08:34
Change icon color programmatically
UIImage *icon = [[UIImage imageNamed:@"image_name.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
cell.imageView.image = icon;
cell.imageView.tintColor = [UIColor colorWithRed:98/255.0f green:126/255.0f blue:255/255.0f alpha:1.0];
@Azuritul
Azuritul / gist:f522a6cd3082a516dc62
Last active March 10, 2016 09:48
Auto layout center element to super view
// Auto layout center element to super view
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]];
//Auto layout
//指定自己width height同高
[self addConstraint:[NSLayoutConstraint constraintWithItem:self
@Azuritul
Azuritul / 0.1-export-plist.sh
Created September 27, 2016 01:19 — forked from mxpr/0.1-export-plist.sh
Export Options Plist flag in xcodebuild
# Switch xcrun to leverage Xcode 7
# Note: This won't be needed once Xcode 7 is released
# and becomes the primary Xcode in use.
export DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer/
# Export Archive
xcrun xcodebuild -exportArchive -exportOptionsPlist exportPlist.plist -archivePath /path/to/app.xcarchive -exportPath /path/to/app.ipa