This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Array { | |
public subscript (safe index: Array.Index) -> Element? { | |
get { | |
return indices ~= index ? self[index] : nil | |
} | |
set { | |
guard let element = newValue else { return } | |
self[index] = element |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bash backup-homebrew.sh >restore-homebrew.sh && chmod +x restore-homebrew.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
brew_command=/usr/local/bin/brew | |
brew_cask_command="$brew_command cask" | |
echo '#!/bin/bash' | |
echo '' | |
echo 'trap ctrl_c INT' | |
echo 'function ctrl_c() {' | |
echo 'echo "** Trapped CTRL-C"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface ObjcClass : NSObject <NSCoding> | |
@property (nonatomic, strong) NSString *name; | |
@end | |
@implementation ObjcClass | |
- (void)encodeWithCoder:(NSCoder *)coder | |
{ | |
[coder encodeObject:_name forKey:@"name"]; | |
} | |
- (instancetype)initWithCoder:(NSCoder *)coder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Create a RAM disk with same perms as mountpoint | |
# Script based on http://itux.idev.pro/2012/04/iservice-speed-up-your-xcode-%D0%BD%D0%B5%D0%BA%D0%BE%D1%82%D0%BE%D1%80%D1%8B%D0%B5-%D1%81%D0%BF%D0%BE%D1%81%D0%BE%D0%B1%D1%8B/ with some additions | |
# Usage: sudo ./xcode_ramdisk.sh start | |
USERNAME=$(logname) | |
TMP_DIR="/private/tmp" | |
RUN_DIR="/var/run" | |
SYS_CACHES_DIR="/Library/Caches" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication *)aApplication didFinishLaunchingWithOptions:(NSDictionary *)aLaunchOptions | |
{ | |
/* for Push Notification in Simulator */ | |
#if TARGET_IPHONE_SIMULATOR | |
NSProcessInfo *sProcessInfo = [NSProcessInfo processInfo]; | |
NSArray *sArguments = [sProcessInfo arguments]; | |
NSUInteger sIndex = [sArguments indexOfObject:@"-option"]; | |
NSString *sPropertyFomatString = [sArguments objectAtIndexOrNil:sIndex+1]; | |
/* format으로 NULL을 전달하면 앱크래시 */ | |
NSPropertyListFormat sPlistFormat; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSArray *sDirs = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *sPath = [[sDirs objectAtIndex:0] stringByAppendingPathComponent:@"timeZoneMap.plist"]; | |
NSDictionary *sZone = [(id)[NSLocale class] performSelector:@selector(ISOCountryCodesToTimeZoneMap)]; | |
NSData *sTmp = [NSPropertyListSerialization dataWithPropertyList:sZone format:NSPropertyListBinaryFormat_v1_0 options:kCFPropertyListImmutable error:nil]; | |
[sTmp writeToFile:sPath atomically:YES]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function()%7Blocation.href='me2day://create/post?body='+encodeURIComponent('%22'+document.title+'%22:'+location.href)+'&tags=me2scrap&returnURL='+encodeURIComponent(location.href);%7D)(); |
NewerOlder