Skip to content

Instantly share code, notes, and snippets.

bool VideoPlayerScene::init() {
if (!Scene::init()) {return false;}
auto visibleSize = Director::getInstance()->getVisibleSize();
auto videoPlayer = cocos2d::experimental::ui::VideoPlayer::create();
videoPlayer->setContentSize(visibleSize);
videoPlayer->setPosition(Vec2(visibleSize.width/2, visibleSize.height / 2));
videoPlayer->setEnabled(false);
videoPlayer->setKeepAspectRatioEnabled(true);
@gin0606
gin0606 / WidgetUtil.h
Last active August 29, 2015 14:03
CocoStudioで深い階層にあるButtonとかを楽に取得するUtil
//
// Created by gin0606 on 2014/07/07.
//
#include "UIWidget.h"
#ifndef __widget_util_H_
#define __widget_util_H_
// Hoge::FugaEnumを前方宣言したい
class Hoge : public TemplateClass<Hoge, FugaEnum> {
public:
enum class FugaEnum {
FOO,
}
}
@gin0606
gin0606 / custom_rules.xml
Created August 1, 2014 11:21
classファイルcompile終わったらjniのheaderを生成するカスタムルール
<?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules" default="help">
<target name="-post-compile">
<javah classpath="./path/to/classes" destdir="./path/to/jni/">
<class name="me.gin0606.ClassName" />
</javah>
</target>
</project>
@gin0606
gin0606 / nippo.rb
Last active September 17, 2015 10:54
日報生成する。元ネタ http://kitak.hatenablog.jp/entry/2014/04/22/013849
require 'octokit'
USER_NAME = ENV['NIPPO_GITHUB_USER_NAME']
client = Octokit::Client.new(login: USER_NAME, access_token: ENV['NIPPO_GITHUB_API_TOKEN'])
events = []
events.concat client.user_events(USER_NAME)
events.concat client.user_public_events(USER_NAME)
activities = {}
main = putStrLn "Project Euler"
p1 :: Integral a => a -> a
p1 n = sum [x | x <- [1..n-1], mod x 3 == 0 || mod x 5 == 0]
p2 :: Integer -> Integer
p2 n = sum $ takeWhile (<=n) [x | x <- fibonacci, even x]
p3 :: Integral a => a -> a
p3 n = maximum $ primeFactorization n
primeFactorization :: (Integral a) => a -> [a]
primeFactorization 0 = []
primeFactorization 1 = []
primeFactorization 2 = [2]
primeFactorization x =
let fstf = firstFactor x
xx = (div x fstf)
in [fstf] ++ primeFactorization xx
firstFactor :: Integral a => a -> a
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
NSString *receiptString = [receipt base64EncodedStringWithOptions:0];
@gin0606
gin0606 / file0.xml
Last active August 29, 2015 14:13
AntでAndroidのpackageをビルド時に変更する ref: http://qiita.com/gin0606/items/c017f60b7276c882dc70
<target name="-package-resources" depends="-crunch">
<exec executable="${aapt}" failonerror="true">
<arg value="package" />
<arg value="-f" />
<arg value="--auto-add-overlay" />
<arg value="-M" />
<arg path="${basedir}/AndroidManifest.xml" />
<arg value="-S" />
<arg path="${resource.absolute.dir}" />
<arg value="-I" />
@gin0606
gin0606 / file0.cpp
Last active August 29, 2015 14:13
cocos2d-xでダウンロードした画像をファイルに保存せず表示する ref: http://qiita.com/gin0606/items/b498b016acbb212dc6f3
auto url = "任意の画像のURL";
auto request = new cocos2d::network::HttpRequest();
request->setUrl(url);
request->setRequestType(cocos2d::network::HttpRequest::Type::GET);
request->setResponseCallback([this, url](cocos2d::network::HttpClient *, cocos2d::network::HttpResponse *response) {
if (!response->isSucceed()) {return;}
auto responseData = response->getResponseData();
auto bytes = reinterpret_cast<unsigned char *>(&(responseData->front()));