Skip to content

Instantly share code, notes, and snippets.

View suin's full-sized avatar
😃

suin

😃
  • Craftsman Software, Inc.
  • Japan Tokyo
View GitHub Profile
@suin
suin / Test.java
Created November 11, 2012 12:59
PHPは引数型のダウンキャストができないなと思ったら。
class Test {
public static void main(String[] args) {
UserRepository userRepository = new UserRepository();
userRepository.persist(new Object());
userRepository.persist(new User());
}
}
class Repository
{
@suin
suin / gist:3923273
Created October 20, 2012 13:27
test 1
{
    "require": {
        "friendsofsymfony/facebook-bundle": "*"
    },
    "minimum-stability": "stable"
}
<?php
/**
* ポリシーエンティティのモック
*/
class Policy
{
/**
* @return DateTime
*/
@suin
suin / gist:3891076
Created October 15, 2012 06:31
XOOPS 構造変更案

1 オーソドックス

xoops_trust_path/modules/xcore
├── actions
├── admin
├── blocks
├── class <-- ここに現在の html/core を入れ込む
├── forms
├── images
@suin
suin / SampleTest.php
Created September 24, 2012 08:46
PHPUnitとかで使えるかもしれないモックHTTPサーバー
<?php
function do_request($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$result = curl_exec($ch);
@suin
suin / gist:3497946
Created August 28, 2012 13:26
(MacOS) sudo fs_usage <apache_proccess_id>
22:24:45.340122 accept F=3 F=60 0.000008 httpd.365955
22:24:45.340127 fcntl F=60 <GETFD> 0.000001 httpd.365955
22:24:45.340127 fcntl F=60 <SETFD> 0.000001 httpd.365955
22:24:45.340168 read F=60 [ 35] 0.000002 httpd.365955
22:24:45.341836 read F=60 B=0x1e7 0.000007 httpd.365955
22:24:45.341917 stat64
^_^)/ {/tmp/php-yaf/tools/cg) (master) (5.4.5)
$ php yaf_cg
Yaf Code Generetor Version 1.0.0
Usage:
yaf_cg ApplicationName [ApplicationPath]
^_^)/ {/tmp/php-yaf/tools/cg) (master) (5.4.5)
$ php yaf_cg foo
DONE
^_^) {/Users/suin) (5.4.5)
$ cd /tmp
^o^) {/tmp) (5.4.5)
$ git clone git://github.com/laruence/php-yaf.git
Cloning into 'php-yaf'...
remote: Counting objects: 407, done.
remote: Compressing objects: 100% (290/290), done.
remote: Total 407 (delta 203), reused 302 (delta 98)
Receiving objects: 100% (407/407), 215.75 KiB | 65 KiB/s, done.
svn
# ディレクトリを作成して移動mkdir -p $HOME/local/src/subversion
cd $HOME/local/src/subversion/
# ソースDL
wget http://www.apache.org/dist/subversion/subversion-1.7.3.tar.gz
# 展開
tar xzf subversion-1.7.3.tar.gz
<?php
class ChangeThemeByModule extends XCube_ActionFilter
{
public function postFilter()
{
$dirname = null;
if ( isset($this->mRoot->mContext->mModule->mXoopsModule) and is_object($this->mRoot->mContext->mModule->mXoopsModule) ) {
$dirname = $this->mRoot->mContext->mModule->mXoopsModule->get('dirname');
}