Skip to content

Instantly share code, notes, and snippets.

View akehoyayoi's full-sized avatar

Yohei Okaya akehoyayoi

View GitHub Profile
@akehoyayoi
akehoyayoi / gist:6102407
Created July 29, 2013 06:05
json4s(lift-json)がバグってる件
// "org.json4s" %% "json4s-native" % "3.2.4"
import org.json4s._
import org.json4s.native.Serialization._
case class AAA(a : Option[Long],b : Option[Long],c : Option[Long])
object JsonTest {
def toJson[Value <: AnyRef](any : Value) : String = {
write(any)(DefaultFormats)
@akehoyayoi
akehoyayoi / HelloWorld.cpp
Last active August 29, 2015 13:56
cocos2d-x v3.0 SceneEditorの読み込みサンプル
bool HelloWorld::init()
{
if (!Layer::init()) return false;
auto reader = cocostudio::SceneReader::getInstance();
// SceneEditorデフォルトに存在するサンプルを読み込む
auto node = reader->createNodeWithSceneFile("FightScene.json");
auto hero = node->getChildByTag(10005); // サンプル上のheroに設定されていたtagの値
@akehoyayoi
akehoyayoi / Version.scala
Created September 27, 2014 04:45
汎用Versionクラス
case class Version(v: Int *) extends Ordered[Version] {
def compare(other: Version) = {
c(v,other.v)
}
def c(v1: Seq[Int], v2: Seq[Int]): Int = {
val diff = v1.headOption.getOrElse(0) compare v2.headOption.getOrElse(0)
if(diff == 0) c(v1.tail,v2.tail) else diff
}
}
@akehoyayoi
akehoyayoi / gist:0466d26ea82d7c74069a
Created May 4, 2015 09:18
cocos2d-x v2系でRPG風に一文字ずつ遅延して表示するクラス
// header file
#include "cocos-ext.h"
#include "CCPointer.h"
// https://github.com/ivzave/cocos2dx-ext/blob/master/CCPointer.h
USING_NS_CC;
USING_NS_CC_EXT;
class CCLabelTTFWithAnimation
@akehoyayoi
akehoyayoi / Program.cs
Last active August 29, 2015 14:26
Guidの部分文字列が被るかどうかのテスト(コンソールアプリ)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
@akehoyayoi
akehoyayoi / convert.sh
Last active August 29, 2015 14:28
from *.png to *.pvr
for i in *.png ; do /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool -e PVRTC --bits-per-pixel-4 -o "${i%.png}.pvr}" -f PVR $i ; done
@akehoyayoi
akehoyayoi / SampleScene.cpp
Created August 29, 2015 01:52
お手軽な端末時間を進めるチートの対策 ref: http://qiita.com/akehoyayoi@github/items/b6dbfd50ebb86bf80dce
void SampleScene::onEnter()
{
〜略〜
// 時間があっているかチェックする
NtpChecker::sharedInstance()->check(this, ntpchecker_selector(SampleScene::bonus));
}
void SampleScene::bonus(NtpResult result)
{
@akehoyayoi
akehoyayoi / convert_data_from_sqlserver_to_mysql.rb
Created September 17, 2015 00:44
convert data from SQLServer to MySQL
def convertLine(line)
line = line.gsub("]","").gsub("[","")
line = line.gsub(" +09:00","")
# 変換候補文字列を抽出
# ex. N'POINT (0 0)' -> GeomFromText('POINT (0 0)')
points = line.scan(/N'POINT \(.+?\)'/)
points.each do |point|
line = line.gsub(point,point.gsub("N'","GeomFromText('").gsub(")'",")')"))
end
line + ";"
@akehoyayoi
akehoyayoi / convert_ddl_from_sqlserver_to_mysql.rb
Created September 17, 2015 00:47
convert ddl from sqlserver to mysql
def convertLine(line)
# 可読性のため一次変数に受ける
result = line.gsub("]","").gsub("[","").gsub("UNIQUEIDENTIFIER","NVARCHAR (38)")
result = result.gsub("NVARCHAR \(MAX\)","NVARCHAR \(256\)")
result.gsub("DATETIMEOFFSET (7)","TIMESTAMP").gsub("sys.geography","geometry")
end
def convertDDL(path)
@inDDL = false
@isGEO = false
@akehoyayoi
akehoyayoi / dynamoTest.py
Last active October 26, 2015 08:41
AWS LambdaのDynamoサンプルコード
# APIGateway + Lambda + DynamoDB
# sample query
# {"tableName":"performance_test","operation":"read","payload": {"test_id":"aaaaaaa"}}
# {"tableName":"performance_test","operation":"delete","payload": {"test_id":"aaaaaaa"}}
# {"tableName":"performance_test","operation":"create","payload": {"test_id":"aaaaaaa","value":"aaaaaaaaa"}}
import boto3
import json
print('Loading function')