Skip to content

Instantly share code, notes, and snippets.

View koriym's full-sized avatar

Akihito Koriyama koriym

View GitHub Profile
@koriym
koriym / gist:3909776
Created October 18, 2012 03:51
Could not load package zendframework/zendframework
When using this composer.json file the following error message appears:
[RuntimeException]
Could not load package zendframework/zendframework in http://packages.zendframework.com: [UnexpectedValueException] Could not parse version constraint develop
[UnexpectedValueException]
Could not parse version constraint develop
{
"repositories": [
{
@koriym
koriym / ApcFacebook.txt
Created October 18, 2012 11:16
ApcFacebook
; http://ja.scribd.com/doc/88689/ApcFacebook
; Slam Defenses & TTL
apc.slam_defense=0
apc.write_lock=0
apc.file_update_protection=2
apc.ttl=0
apc.user_ttl=0
apc.gc_ttl=3600
; Filters
apc.max_file_size=1M
@koriym
koriym / rm-r
Created January 30, 2013 12:48
recursively remove a directory by PHP closure
$rm = function ($dir) use (&$rm) {
foreach(glob($dir . '/*') as $file) {
is_dir($file) ? $rm($file) : unlink($file);
rmdir($file);
}
};
// delete
$rm('./tmp');
@koriym
koriym / gist:4715085
Created February 5, 2013 15:20
macports maintenance
sudo port sync
sudo port selfupdate
sudo port clean –dist outdated
sudo port upgrade outdated
sudo port -u uninstall
@koriym
koriym / gist:4721099
Created February 6, 2013 08:06
PHP5.4でのpecl/imagickインストール ※PHP5.4ではimagick-betaでないとコンパイルできない問題 https://bugs.php.net/bug.php?id=61501&edit=3
sudo port install ImageMagick
pecl download imagick-beta
tar xvzf imagick-3.1.0RC2.tgz
cd imagick-3.1.0RC2
phpize
./configure --with-imagick=/opt/local
make
sudo make install
@koriym
koriym / gist:4743773
Created February 9, 2013 04:00
短いハッシュ base64_encodeを使ってハッシュを圧縮
<?php
$shortHash = function ($data, $algo = 'CRC32') {
return strtr(rtrim(base64_encode(pack('H*', $algo($data))), '='), '+/', '-_');
};
$a = 'hello';
echo $a;
echo md5($a) . PHP_EOL; // hello5d41402abc4b2a76b9719d911017c592
echo CRC32($a) . PHP_EOL; // 907060870
@koriym
koriym / gist:5549847
Created May 9, 2013 19:23
vhosts.conf for osx: /private/etc/apache2/extra/httpd-vhosts.conf
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
@koriym
koriym / gist:5574222
Last active December 17, 2015 07:39
Fatal error: Method BEAR\Resource\Request::__toString()
<?php
class A
{
public function __toString()
{
try {
resource();
} catch (Exception $e) {
return '';
}
@koriym
koriym / app.yml
Last active December 17, 2015 10:39
appEngine for PHPの最小設定 app.yml
application: bear-sunday
version: 1
runtime: php
api_version: 1
handlers:
- url: /.*
script: BEAR.Package/apps/Helloworld/public/basic.php
@koriym
koriym / gist:6270836
Created August 19, 2013 16:07
a first generated aspect weaved code.
class MockMethod_ray000000003b0690510000000023341af3 extends Ray\Aop\Mock\MockMethod
{
private $___initialized = false;
public $bind;
public function returnSame($a)
{
if ($this->___initialized || !isset($this->bind[__FUNCTION__])) {
return call_user_func_array('parent::' . __FUNCTION__, func_get_args());
}
$this->___initialized = true;