Skip to content

Instantly share code, notes, and snippets.

@neiraza
neiraza / HomeButtonReceiverActivity.java
Created February 12, 2014 07:24
ホームボタンをタップした際のイベントを取得しちゃる
public class HomeButtonReceiverActivity extends Activity {
private HomeButtonReceiver mHomeButtonReceiver;
private IntentFilter mIntentFilter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//TODO ホームボタン押された時の Receiver の登録
@neiraza
neiraza / only-debug-log-Prefix.pch
Last active August 29, 2015 13:56
NSLogをDEBUG時しか使わせない
#ifdef DEBUG
#define LOG(...) NSLog(__VA_ARGS__)
#define LOG_PRINTF(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#define LOG_FUNC NSLog(@"%s", __func__)
#define LOG_METHOD_AND_ABORT LOG_METHOD; abort()
#else
#define LOG(...)
#define LOG_PRINTF(FORMAT, ...)
#define LOG_FUNC
#define LOG_METHOD_AND_ABORT
@neiraza
neiraza / CoreData-import-Prefix.pch
Last active August 29, 2015 13:56
CoreDataのサンプルで泣いているあなたへ
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#endif
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
// MKAnnotationViewを拡張した独自Annotation
if ([view.annotation isMemberOfClass:[HogeAnnotationEx class]]) {
MapPin *pin = (HogeAnnotationEx *)view.annotation;
// 独自Annotationにタイプとか定義しとく
if (pin.type == hoge) {
LOG(@"user");
@neiraza
neiraza / hoge.html
Created January 22, 2014 05:02
smatyでcssとかのキャッシュ対策
<link rel="stylesheet" href="/style/smart/table.css?{($smarty.now|date_format:"%Y-%m-%d %H:%M:%S")}" type="text/css" />
alias ls='ls --color'
export LV='-Ou8 -c'
export LESS='-R'
bindkey -e
bindkey '^R' history-incremental-pattern-search-backward
bindkey '^S' history-incremental-pattern-search-forward
HISTFILE=~/.zsh_history
@neiraza
neiraza / AppDelegate.m
Created December 3, 2013 01:55
Background Fetch (iOS7) sample
if ([UiUtil isNotLessiOS7]) {
//UIApplicationBackgroundFetchIntervalMinimum or NN seconds
[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:600];
}
- (void)updateAppIconBadge
{
LOG(@">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>updateAppIconBadge<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
// 設定する前に、設定済みの通知をキャンセルする
@neiraza
neiraza / UIAlertView+UIAlertView_BlocksExtension.h
Created September 6, 2013 04:00
UIAlertViewでdelegateをダラダラ書くのは嫌だ
#import <UIKit/UIKit.h>
@interface UIAlertView (UIAlertView_BlocksExtension)
typedef void (^UIAlertViewCallback_t)(NSInteger buttonIndex);
- (id)initWithTitle:(NSString *)title
message:(NSString *)message
callback:(UIAlertViewCallback_t)callback
cancelButtonTitle:(NSString *)cancelButtonTitle
otherButtonTitles:(NSString *)otherButtonTitles, ...;
@neiraza
neiraza / NSDate+カテゴリさま
Created September 3, 2013 08:44
UTCな時間(文字列)をNSDateなローカル時間に変換する
- (NSDate *)toLocalTime
{
NSTimeZone *tz = [NSTimeZone defaultTimeZone];
NSInteger seconds = [tz secondsFromGMTForDate:self];
return [NSDate dateWithTimeInterval:seconds sinceDate:self];
}
- (NSDate *)toGlobalTime
{
NSTimeZone *tz = [NSTimeZone defaultTimeZone];
@neiraza
neiraza / FormActivity.java
Created August 29, 2013 01:01
今日は僕の誕生日なので、誕生日を公開するSpinnerネタ
/**
* Created by togu on 2013/07/23.
*/
public class FormActivity extends Activity implements OnItemSelectedListener {
private Spinner birthdayPermission;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);