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
| - (void)test_stepByStep_withCapacity | |
| { | |
| NSMutableArray *keys = [NSMutableArray new]; | |
| NSMutableArray *values = [NSMutableArray new]; | |
| srand(0x21112005); | |
| int entryCount = 1000000; | |
| for (int ix = 0, ixMax = entryCount; ix < ixMax ; ix++) { | |
| NSString *key = [NSString stringWithFormat:@"Key#%d", (ix + 1)]; | |
| NSString *value = [NSString stringWithFormat:@"Value with %d", rand()]; | |
| [keys addObject:key]; |
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
| hash2id={"replace1":"with1","replace2":"with2"} | |
| xml_files=`find "/path/to/folder" -type f -name '*.xml'`.strip.split("\n") | |
| xml_files.each do |xml_file| | |
| puts "Processing #{xml_file}" | |
| original_text=File.read(xml_file) | |
| text=original_text.dup | |
| hash2id.each do |hash,id| | |
| text.gsub!(hash.to_s, id) |
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
| # Select Xcode | |
| sudo xcode-select --switch /Applications/Xcode.app/ | |
| # run app with lldb | |
| xcrun lldb ...path to application.../Contents/MacOS/binaryname | |
| (lldb) run | |
| # pause app | |
| 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
| CABasicAnimation *color = [CABasicAnimation animationWithKeyPath:@"borderColor"]; | |
| color.fromValue = (id)[UIColor clearColor].CGColor; | |
| color.toValue = (id)[UIColor redColor].CGColor; | |
| CABasicAnimation *width = [CABasicAnimation animationWithKeyPath:@"borderWidth"]; | |
| width.fromValue = @0; | |
| width.toValue = @1.5; | |
| CAAnimationGroup *both = [CAAnimationGroup animation]; | |
| both.duration = 0.5; | |
| both.animations = @[color, width]; | |
| both.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; |
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
| > find /Applications/Xcode.app -name clang | |
| # Pick one | |
| > /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c /dev/null -dM -E |
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
| __block dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); | |
| [self callAsyncBlock:^() { | |
| // Do some work | |
| dispatch_semaphore_signal(semaphore); | |
| }]; | |
| // Wait until the semaphore has been signaled | |
| dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); | |
| dispatch_release(semaphore); |
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
| Find: ^([+-] \(.* \*\))( ) | |
| Replace: \1 |
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
| find Classes -name '*.[hmM]' -print0|xargs -0 wc -l |
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
| cd "$DATABASE_LOCATION" | |
| echo '.dump'|sqlite3 $DB_NAME|sqlite3 repaired_$DB_NAME | |
| mv $DB_NAME corrupt_$DB_NAME | |
| mv repaired_$DB_NAME $DB_NAME |
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
| function parse_branch { | |
| local BRANCH=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/') | |
| if [ -z "$BRANCH" ] | |
| then | |
| BRANCH=$(hg branch 2>/dev/null) | |
| if [ -n "$BRANCH" ] | |
| then | |
| BRANCH="("$BRANCH")" | |
| fi | |
| fi |