Skip to content

Instantly share code, notes, and snippets.

@gmodecorp
gmodecorp / 20130513_1
Last active August 29, 2015 14:05
CCNodeのポジション指定
#define Pos( obj, ancher, point ) obj->setAnchorPoint(ancher); obj->setPosition(point)
#define CCAncherLT ( CCPointMake(0.f, 1.f) )
#define CCAncherCT ( CCPointMake(0.5f, 1.f) )
#define CCAncherRT ( CCPOne )
#define CCAncherLC ( CCPointMake(0.f, 0.5f) )
#define CCAncherCC ( CCPHalf )
#define CCAncherRC ( CCPointMake(1.f, 0.5f) )
#define CCAncherLB ( CCPZero )
#define CCAncherCB ( CCPointMake(0.5f, 0.f) )
#define AtIndex( array, index, type ) ( dynamic_cast<type> (array->objectAtIndex(index)) )
#define ForKey( dic, key, type ) ( dynamic_cast<type> (dic->objectForKey(key)) )
#define GetLayer(scene, type) ( AtIndex(scene->getChildren(), 0, type) )
#define GetSecond() ( gettimeofday_sec() )
inline double gettimeofday_sec()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec + tv.tv_usec * 1e-6;
}
@gmodecorp
gmodecorp / 20130527_1
Last active August 29, 2015 14:05
Web Server初期化・起動処理
# セットアップ処理をしています。
sub BUILD {
my $self = shift;
$self->setup_dispatcher();
$self->setup_view();
$self->setup_context();
}
# PSGIの仕様にそって、関数の参照を返却しています。
sub to_app {
@gmodecorp
gmodecorp / 20130527_2.pl
Last active August 29, 2015 14:05
リクエスト毎の処理
sub dispatch {
my $c = shift;
# ユーザが指定された処理を、Mouse::Roleにて差し込めるためのHook.
$c->INITIALIZE;
# 実行するロジック関数を見つける
my ($controller,$action) = $c->dispatcher->match( $c );
# 見つからなければ、404
if ( !$controller or !$action ) {
@gmodecorp
gmodecorp / 20130722_1.sass
Created August 26, 2014 06:47
ベンダープレフィックス設定
// ベンダープレフィックス設定
$experimental-support-for-microsoft: false;
$experimental-support-for-webkit: true;
$experimental-support-for-mozilla: true;
$experimental-support-for-opera: false;
// compassでこんな感じに書くと
@include border-radius(5px);
// このように上記で設定した通りにCSSが出力されます
<!-- このclass名だと状況を特定しすぎているため、汎用的でなく他の場所で使いづらい -->
<button class="startBtn">ボタンだよ!</button>
<!-- baseBtnで共通スタイルをあてて、長さ、重要等のclassをモジュール的に付け足していく -->
<button class="baseBtn">ボタンだよ!</button>
<button class="baseBtn long primary">ボタンだよ!</button>
@gmodecorp
gmodecorp / 20140805_1.sh
Created August 26, 2014 07:17
yum install supervisor
sudo yum install supervisor