This file contains 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
class Boo(object): | |
pass | |
b = Boo() | |
def test(n): | |
b.n = n | |
m = 0 + n # int オブジェクトをコピー | |
print(n, b.n is m) |
This file contains 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
/* 配列の配列からオブジェクトを検索しindexPathを返す */ | |
- (NSIndexPath *)indexPathOfItem:(id)item { | |
__block NSIndexPath *indexPath = nil; | |
[groups_ enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { | |
NSInteger row = [(NSArray *)obj indexOfObject:item]; | |
if (row != NSNotFound) { | |
indexPath = [NSIndexPath indexPathForRow:row inSection:idx]; | |
*stop = YES; |
This file contains 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
NSRange range; | |
NSString *str = @""; | |
if (type == PostTweetTypePublicRepyType) { | |
str = @"Reply"; | |
range = NSMakeRange([str length], 0); | |
} else if (type == PostTweetTypeRetweetType) { | |
str = @"Retweeted"; | |
range = NSMakeRange(0, 0); | |
} if (type == PostTweetTypePublicRepyToUserType) { |
This file contains 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
UIKIT_EXTERN NSString *const UIApplicationDidEnterBackgroundNotification __attribute__((weak_import)); | |
UIKIT_EXTERN NSString *const UIApplicationWillEnterForegroundNotification __attribute__((weak_import)); |
This file contains 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 user_error_handler(func): | |
def wrapped(*args, **kwargs): | |
try: | |
response = func(*args, **kwargs) | |
except (InvalidUser,), e: | |
logger.error('%s: %s' % (func.__name__, str(e),)) | |
response = HttpResponseNotFound('Not found') | |
return response | |
return wrapped |
This file contains 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
<?php | |
function console_styles() { | |
return array( | |
'heading1' => "\033[1;30;46m", | |
'heading2' => "\033[1;35m", | |
'heading3' => "\033[1;34m", | |
'option' => "\033[40;37m", | |
'command' => "\033[1;40;37m", | |
'error' => "\033[0;31m", |
This file contains 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
<div id="fb-root"> | |
<script type="text/javascript"> | |
window.fbAsyncInit = function() { | |
FB.init({ | |
appId: '123456789xxxxxx', | |
status: true, | |
cookie: true, | |
xfbml: true | |
}); | |
}; |
This file contains 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
tell application "Stickies" | |
activate | |
set w to {} | |
tell application "System Events" | |
tell application process "Stickies" | |
repeat with win in every window | |
set w to w & {position of win} | |
end repeat |
This file contains 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
<?php | |
$salt = genrandom(40); | |
$seed = genrandom(29, "0123456789"); | |
echo "\tConfigure::write('Security.salt', '$salt');\n"; | |
echo "\tConfigure::write('Security.cipherSeed', '$seed');\n"; | |
function genrandom($len, $salt = null) { | |
if (empty($salt)) { |
OlderNewer