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
| from django import template | |
| register = template.Library() | |
| @register.filter | |
| def gt(a, b): | |
| return a > b | |
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 threading | |
| import time | |
| sort_list = [1, 3, 6, 8, 10, 33, 44, 23] | |
| def sort(lis): | |
| answer_list = [] | |
| for num in lis: | |
| thread = threading.Thread(target=sleep, args=(num, answer_list)) |
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
| def fizz_check(num): | |
| return "fizz" if num % 3 == 0 else "" | |
| def buzz_check(num): | |
| return "buzz" if num % 5 == 0 else "" | |
| def fizz_buzz(num): | |
| return [(fizz_check(n) + buzz_check(n)) or n for n in range(1, num + 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
| CCProgressTimer *time_bar = [CCProgressTimer progressWithSprite:[CCSprite spriteWithFile:@"timebar.png"]]; | |
| //タイムバーの生成を行う。 | |
| time_bar.percentage = 100.0; | |
| //時間切れでゲームを止めるので初期値を100にする。 | |
| time_bar.type = kCCProgressTimerTypeBar; | |
| //タイムバーのタイプレクタングルが他にある。 | |
| time_bar.barChangeRate = ccp(0, 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
| CCSprite *rotete_object = [CCSprite initWithFile:@"hadaka_oyaji.png"]; | |
| CCRotateBy *rotateby_clockwise = [CCRotateBy actionWithDuration:0.1 angle:180]; | |
| [rotate_object runAction: [CCRepeatForever actionWithAction:rotateby_clockwise]]; | |
| //これだと、時計回りに永遠に回転し続ける。 | |
| CCRotateBy *rotateby_rev_clockwise = [CCRotateBy actionWithDuration:0.1 angle:-180]; | |
| //マイナス、を付けている | |
| [rotate_object runAction: [CCRepeatForever actionWithAction:rotateby_rev_clockwise]]; | |
| //反時計周りに回転し続ける。 |
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
| NSString *str = @"hogehogefugao"; | |
| NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:@"(hoge).+(fugao)" options:0 error:nil]; | |
| NSString *new_str = [regexp | |
| stringByReplacingMatchesInString:str options:0 range:NSMakeRange(0, str.length) withTemplate:@"$1山$2"]; | |
| //new_strは hoge山fugaoになります。 |
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
| NSMutableDictionary *mutable_dic = [[NSMutableDictionary alloc] initWithCapacity:2]; | |
| //辞書の生成 | |
| int i; | |
| for (i = 0; i < 100; i++) { | |
| NSDictionary *dic = [NSDictionary dictionaryWithObject:@"hoge" forKey:@"Key"]; | |
| [mutable_dic addEntriesFromDictionary:dict]; | |
| } |