Skip to content

Instantly share code, notes, and snippets.

@yuya-takeyama
yuya-takeyama / README.md
Created October 22, 2011 12:10
`install* sub-command for phpenv. *NOT* for rbenv.

phpenv install

It provides install sub-command for phpenv using php-build.

Requirements

@xenji
xenji / compile_flags.txt
Created March 7, 2012 11:01
Compile flags for xcache and memcache for php5.4.0
CFLAGS="-D_REENTRANT -D_THREAD_SAFE -O3 -pipe -pthread" CXXFLAGS="-D_REENTRANT -D_THREAD_SAFE -O3 -pipe -pthread" ./configure
<?php
require __DIR__.'/../vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$client = stream_socket_client('tcp://127.0.0.1:4000');
$conn = new React\Socket\Connection($client, $loop);
@igorw
igorw / gist:5894929
Created June 30, 2013 12:11
Conditional Strategy Stack Middleware.
<?php
class Conditional implements HttpKernelInterface {
private $app;
private $prefix;
private $wrappedApp;
public function __construct(HttpKernelInterface $app, $prefix, $spec) {
$this->app = $app;
$this->prefix = $prefix;
div.description a.autolink
{
display: inline-block;
max-width: 250px;
text-overflow: ellipsis;
overflow: hidden;
}
@yuya-takeyama
yuya-takeyama / ArrayObject.php
Created June 29, 2011 16:49
Enumerable trait implementation works on PHP5.4.
<?php
namespace Rubyish;
use Rubyish\Enumerable;
class ArrayObject extends \ArrayObject
{
use Enumerable;
}
@madrobby
madrobby / gist:4161897
Created November 28, 2012 15:16
Retina screen media query
@media (min--moz-device-pixel-ratio: 1.5),
(-o-min-device-pixel-ratio: 3/2),
(-webkit-min-device-pixel-ratio: 1.5),
(min-device-pixel-ratio: 1.5),
(min-resolution: 144dpi),
(min-resolution: 1.5dppx) {
/* Retina rules! */
}
@sstephenson
sstephenson / super.bash
Last active January 30, 2017 01:40
`super` in Bash
#!/usr/bin/env bash
source super.bash
foo() {
echo hello
}
super_function foo
foo() {
@dbu
dbu / Vagrantfile
Created November 13, 2012 09:26
vagrant setup
# -*- mode: ruby -*-
# vi: set ft=ruby :
this_dir = File.dirname(__FILE__) + "/"
require this_dir + "vagrant/hostmaster.rb"
Vagrant::Config.run do |config|
# define some colors for our output
def colorize(text, color_code) "#{color_code}#{text}\033[0m" end
@ziadoz
ziadoz / OpenStruct.php
Last active August 2, 2019 10:35
OpenStruct and Struct in PHP
<?php
class OpenStruct extends ArrayObject
{
public function __construct($input = array())
{
parent::__construct($input, static::ARRAY_AS_PROPS);
}
public function offsetSet($key, $value)
{