Skip to content

Instantly share code, notes, and snippets.

View mtsd's full-sized avatar

Kosuke Matsuda mtsd

  • Tokyo, Japan
View GitHub Profile
@mtsd
mtsd / gist:7096415
Last active December 26, 2015 04:49
libxml2で属性(xsi:nil="true")を取得する
xmlNodePtr cur = ...;
/*****
(1)
*/
xmlChar *prop = xmlGetProp(cur, (const xmlChar *) "nil");
// xmlChar *prop = xmlGetNsProp(cur, (const xmlChar *) "nil", (const xmlChar *) "http://www.w3.org/2001/XMLSchema-instance");
NSLog(@"prop : %p", prop);
if (prop != NULL) {
@mtsd
mtsd / 1_install_openssl
Last active December 14, 2019 03:14
install Ruby 2.0 with Homebrew
$ brew install openssl
==> Downloading http://openssl.org/source/openssl-1.0.1e.tar.gz
######################################################################## 100.0%
==> perl ./Configure --prefix=/usr/local/Cellar/openssl/1.0.1e --openssldir=/usr/local/etc/openssl zlib-dynamic shared darwin64-x86_64-cc
==> make
==> make test
==> make install MANDIR=/usr/local/Cellar/openssl/1.0.1e/share/man MANSUFFIX=ssl
==> Caveats
To install updated CA certs from Mozilla.org:
$ brew install tmux
==> Installing tmux dependency: pkg-config
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/pkg-config-0.27.1.mountainlion.bottle.tar.gz
######################################################################## 100.0%
==> Pouring pkg-config-0.27.1.mountainlion.bottle.tar.gz
/usr/local/Cellar/pkg-config/0.27.1: 9 files, 624K
==> Installing tmux dependency: libevent
==> Downloading https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz
######################################################################## 100.0%
==> ./configure --disable-debug-mode --prefix=/usr/local/Cellar/libevent/2.0.20
@mtsd
mtsd / GAMacros_v1.h
Last active December 9, 2015 22:08
Google Analytics for iOS 's useful macros
#import "GANTracker.h"
/*
Google Analytics's Macros
http://d.hatena.ne.jp/ninjinkun/20110115/1295074900
http://tkyk.name/blog/2011/09/19/iOS-Xcode-iphone_google-analytics-for-ios/
http://d.hatena.ne.jp/diveintounlimit/20120512/1336837189
*/
#define GA_DEBUG_FLAG 0
@mtsd
mtsd / 1_sample.sql
Last active January 25, 2025 15:14
SQLite snippets
/*
CREATE文における各種データ型の設定
擬似的にBOOLEAN型を設定
*/
CREATE TABLE IF NOT EXISTS tests (id INTEGER PRIMARY KEY AUTOINCREMENT,
memo TEXT,
image BLOB,
type INTEGER,
favorite BOOLEAN NOT NULL DEFAULT 0 CONSTRAINT testsFavorite CHECK (favorite IN (0, 1) OR favorite IS NULL),
createdAt DATETIME
@mtsd
mtsd / gist:4158797
Created November 28, 2012 03:10
install Subversion with Homebrew, but error.
$ brew install subversion
==> Installing subversion dependency: pkg-config
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/pkg-config-0.27.1.mountainlion.bottle.tar.gz
######################################################################## 100.0%
==> Pouring pkg-config-0.27.1.mountainlion.bottle.tar.gz
/usr/local/Cellar/pkg-config/0.27.1: 9 files, 624K
==> Installing subversion dependency: neon
==> Downloading http://www.webdav.org/neon/neon-0.29.6.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/neon/0.29.6 --enable-shared --disable-static --with-ssl
@mtsd
mtsd / 1_appDelegate.m
Created November 8, 2012 08:38
アプリ起動時、バックグランドからの復帰時の傾きを考慮したview情報を取得するサンプル
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
NSLog(@"%s", __func__);
UIViewController *controller = self.window.rootViewController;
NSLog(@"frame >>>>>>>>>>> %@", NSStringFromCGRect(controller.view.frame));
NSLog(@"bounds >>>>>>>>>>> %@", NSStringFromCGRect(controller.view.bounds));
return YES;
@mtsd
mtsd / KMDevice.h
Created November 2, 2012 06:00
UIDevice+deviceToken+UUID (iOS < 6)
#import <Foundation/Foundation.h>
@interface KMDevice : NSObject
@property (nonatomic, readonly) NSString *uuid;
@property (nonatomic, readonly) NSString *deviceToken;
+ (KMDevice *)sharedDevice;
- (void)registerDeviceToken:(NSData *)devToken;
@mtsd
mtsd / 1.snippet.m
Last active March 26, 2017 23:08
Objective-C code snippet
/**
乱数生成
*/
// 一般的な方法
srand((unsigned int)time(NULL)); // 初期化
int r = rand() % 10 + 1;
// または
int r = arc4random() % 10;
@mtsd
mtsd / capture_uiview.m
Created October 31, 2012 08:19
capture UIView as UIImage
- (IBAction)capture:(id)sender
{
UIImage *image = [self imageByCapture:self.view];
self.imageView.image = image;
}
- (UIImage *)imageByCapture:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];