Skip to content

Instantly share code, notes, and snippets.

View hajipy's full-sized avatar

Kenichi Saito hajipy

  • CureApp Inc.
  • Chiba, Japan
  • X @hajipy
View GitHub Profile
- (NSManagedObjectContext*)managedObjectContext {
if (_managedObjectContext) {
return _managedObjectContext;
}
NSManagedObjectModel* managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil];
NSPersistentStoreCoordinator* persistantStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:managedObjectModel];
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);;
[connection sendDidRecieveData:[@"[{\"id\": 1, \"text\": \"object0\", \"created_at\": \"Sat Aug 20 12:34:56 +0000 2011\", \"user\": {\"id\":\"1\", \"screen_name\": \"testuser0\"} }]" dataUsingEncoding:NSUTF8StringEncoding]];
@hajipy
hajipy / gist:1203046
Created September 8, 2011 09:52
ラジオボタンに応じて対応するチェックボックスのdisableを切り替えるJS
$(document).ready(function() {
$('input[name="hoge"]:radio').change(function() {
if ($(this).val() == 'piyo') {
$('input[name="fuga"]:checkbox').removeAttr('disabled');
}
else {
$('input[name="fuga"]:checkbox').attr('disabled', 'disabled');
}
});
});
@hajipy
hajipy / gist:1261081
Created October 4, 2011 07:33
how to install phpunit
sudo pear upgrade PEAR
sudo pear channel-discover pear.phpunit.de
sudo pear config-set auto_discover 1
sudo pecl install xdebug
sudo pear install pear.phpunit.de/PHPUnit
int kotoko() {
if (hoge) {
if (fuga) {
if (piyo) {
if (is18years_old) {
hiwai();
}
else {
kimoi();
}
2011-11-10 05:55:33 +0000: (null)
2011-11-10 05:55:33 +0000: account/verify_credentials.json?include_entities=1
2011-11-10 05:55:33 +0000: (null)
2011-11-10 05:55:34 +0000: GET
2011-11-10 05:55:34 +0000: blocks/blocking/ids.json
2011-11-10 05:55:34 +0000: (null)
2011-11-10 05:55:34 +0000: GET
2011-11-10 05:55:34 +0000: friendships/no_retweet_ids.json
2011-11-10 05:55:34 +0000: (null)
2011-11-10 05:55:34 +0000: (null)
curl "https://api.twitter.com/statuses/user_timeline.json?screen_name=poyow&include_rts=1&include_entities=1&count=100"
{"error":"Rate limit exceeded. Clients may not make more than 150 requests per hour.","request":"\/statuses\/user_timeline.json?screen_name=poyow&include_rts=1&include_entities=1&count=100"}
@hajipy
hajipy / .screenrc
Created November 30, 2011 08:14
my .screenrc
defencoding UTF-8
escape ^Z^Z
hardstatus alwayslastline "%`%-w%{=b bw}%n %t%{-}%+w"
defscrollback 100000
// managedObjectModelからFetchedPropertyを検索し、ソート条件を追加
// NSPersistentStoreCoordinatorを作成する前に行うこと!
for (NSEntityDescription* entity in [managedObjectModel entities]) {
for (NSPropertyDescription* property in [entity properties]) {
if ([property isKindOfClass:[NSFetchedPropertyDescription class]]) {
NSFetchedPropertyDescription* fetchedProperty = (NSFetchedPropertyDescription*) property;
NSFetchRequest* fetchRequest = [fetchedProperty fetchRequest];
if ([[[[fetchRequest entity] propertiesByName] allKeys] containsObject:@"twId"]) {
NSSortDescriptor* sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"twId" ascending:NO] autorelease];
@hajipy
hajipy / gist:2490112
Created April 25, 2012 14:31
[NSDictionary isNull]
@implementation NSDictionary (isNull)
- (BOOL)isNull:(id)aKey
{
id value = [self objectForKey:aKey];
return (value == nil || [value isEqual:[NSNull null]]);
}
@end