Skip to content

Instantly share code, notes, and snippets.

View tadamatu's full-sized avatar

Tadashi Matsuda tadamatu

  • BASE.inc
  • Kanagawa, Japan
View GitHub Profile
@tadamatu
tadamatu / postFacebook.m
Created July 22, 2015 14:25
Facebookへの投稿
//Facebookへの投稿
//※Social.frameworkの追加が必要
void postFacebook(NSString *text, NSString *url, NSString *image) {
SLComposeViewController *facebookPostVC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[facebookPostVC setInitialText:text];
[facebookPostVC addURL:[NSURL URLWithString:url]];
[facebookPostVC addImage:[UIImage imageNamed:image]];
[facebookPostVC setCompletionHandler:^(SLComposeViewControllerResult result) {
if (result == SLComposeViewControllerResultDone) {
//投稿完了の処理
@tadamatu
tadamatu / postTwitter.m
Created July 22, 2015 14:26
Twitterの投稿
//Twitterの投稿
//※Social.frameworkの追加が必要(iOS6.0以上の場合)
//※Twitter.frameworkの取り込みが必要(iOS5.0以下の場合)
void postTwitter(NSString *text, NSString *url, NSString *image) {
NSURL* appURL = [NSURL URLWithString:url];
// iOS Version
NSString *iosVersion = [[[UIDevice currentDevice] systemVersion] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
// Social.frameworkを使う
if ([iosVersion floatValue] >= 6.0) {
@tadamatu
tadamatu / postLine.m
Last active August 29, 2015 14:25
Lineへの投稿
//Lineのテキストを投稿
void postLine(NSString *text) {
//アプリ:LINE に直接遷移して投稿
text = [text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *LINEUrlString = [NSString stringWithFormat:@"line://msg/text/%@", text];
//LINEインストールの確認
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:LINEUrlString]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:LINEUrlString]];
//LINEは投稿完了を受け取れないため、メソッドコールと投稿完了がイコールとなる
@tadamatu
tadamatu / stringReplace.cpp
Created July 25, 2015 01:46
文字列の置換
//[cocos2d-x]
//文字列の置換
//target 対象文字列
//from 検索する文字列(置換される文字列)
//to 置換する文字列
//Return 置換後文字列
std::string stringReplace(const std::string target, const std::string from, const std::string to) {
std::string result = target;
std::string::size_type pos = 0;
while(pos = result.find(from, pos), pos != std::string::npos) {
@tadamatu
tadamatu / trim.cpp
Created July 25, 2015 01:49
トリミング関数
//[cocos2d-x]
//トリミング関数
//str 対象文字列
//[trimCharacterList] トリミングしたい文字
//Return トリミング後の文字列
std::string trim(const std::string& str, const char* trimCharacterList = "; \t\v\r\n\"\'") {
std::string result;
std::string::size_type left = str.find_first_not_of(trimCharacterList);
if (left != std::string::npos) {
@tadamatu
tadamatu / split.cpp
Last active August 29, 2015 14:25
文字列をデリミタで分解しリスト化する関数
//[cocos2d-x]
//文字列をデリミタで分解しリスト化する関数
//str 対象文字列
//delim デリミタ
//Return 分解後リスト
std::list<std::string> split(std::string str, std::string delim) {
std::list<std::string> result;
long cutAt;
@tadamatu
tadamatu / gist:3922379
Created October 20, 2012 06:36
html5 mobile template <<No User scalable & jQuery & jQuery Mobile>>
<!DOCTYPE html>
<html lang="ja">
<head>
<title>XXXX</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,maximum-scale=1">
<meta name="keywords" content="XXXX,Search Keywords,XXXX">
<meta name="description" content="XXXX Page description XXXX">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
@tadamatu
tadamatu / gist:3966823
Created October 27, 2012 23:21
Objective-c Event
/* ========================================
イベント実装のサンプル
xxx.h/xxx.m イベント通知側
yyy.h/yyy.m イベント受け側
======================================== */
/* ========================================
Step1.プロトコルを定義(xxx.h はたは 別ファイル)
======================================== */
@protocol aaaDelegate <NSObject>
@tadamatu
tadamatu / gist:4005648
Created November 3, 2012 02:58
Screen State Library
/* ========================================
ScreenStateLibrary.h
======================================== */
#import <Foundation/Foundation.h>
@interface ScreenStateLibrary : NSObject
//4インチスクリーン判定
//YES=4inch、NO=4inch以外(3.5inch or iPad)
+(BOOL)is4inch;
@tadamatu
tadamatu / gist:4102787
Created November 18, 2012 01:59
[BlobMigrationRecord Class] get_new_blob_key() method for Java
package com.example.myproject;
import com.google.appengine.api.blobstore.BlobKey;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.EntityNotFoundException;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;