Skip to content

Instantly share code, notes, and snippets.

View clue's full-sized avatar

Christian Lück clue

View GitHub Profile
@clue
clue / README.md
Last active August 29, 2015 13:57
Running Ratchet test suite in a clean schroot

This gist demonstrates how to use a transient (temporary) schroot environment to set up a controlled environment to run the Ratchet test suite. It assumes you're running this on a recent version of Ubuntu (a virtual machine will do as well).

  • We want to run the test suite in isolation without installing the required tools on our host.
  • Instead, all tools will be installed in a transient schroot that will be reset whenever we leave it.
  • The schroot is a convenient wrapper to set up a blank system in a chroot, but still provides access to your home directory where the workspace (Ratchet) is installed.
  • This allows us to easily hack the source code on the host system and running exactly the same code in the schroot test environment.
  • As such, you can read/write to your home directory from within your schroot, which is convenient in our case. Obviously, this is not a safe option if you're running untrusted code.
  • We use debootstrap to set up a new Ubuntu Precise (12.04 LTS) VM.
$buffer = '';
$conn->on('data', function($data, $conn) use (&$buffer) {
$buffer .= $data;
// check to see if the buffer contains any line feeds (detect end of line)
while (false !== ($pos = strpos($buffer, PHP_EOL))) {
// get the first line from the buffer (up to the EOL)
$line = substr($buffer, 0, $pos);
// remove the line from the buffer (advance behind the EOL)
git clone https://github.com/reactphp/react source
cd source
# list all branches that should be preserved
# only version branches listed, as to skip WIP branches
git branch 0.3 origin/0.3
git branch 0.4 origin/0.4
#master is already included (default from clone)
# remove reference from origin to speed up rewriting its references
<?php
class EnterpriseApi extends Clue\React\Soap\Proxy
{
public function __call($method, $args)
{
if (!in_array($method, array('DoAuthenticateUserWithPlaintextPassword', 'BypassTheAuthenticationFramework', 'debug'))) {
$d = new React\Promise\Deferred();
$d->reject(new \Exception('This is an enterprise API!!11'));
return $d->promise();
@clue
clue / ssl.php
Created August 31, 2014 09:46
Reproduce SSL buffering issue
<?php
use React\SocketClient\Connector;
use React\SocketClient\SecureConnector;
use React\Socket\Server;
use React\Stream\Stream;
require __DIR__ . '/../vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
@clue
clue / gist:4428883931c295ec82db
Created October 20, 2014 12:38
AMI command: sip show peers
Action: command
Command: sip show peers
Response: Follows
Privilege: Command
Name/username Host Dyn Forcerport ACL Port Status Description
100 (Unspecified) D a 0 UNKNOWN
111 (Unspecified) D a 0 UNKNOWN
1111 (Unspecified) D a 0 Unmonitored
114 (Unspecified) D a 0 UNKNOWN
@clue
clue / gist:29f48b134f273efcfcfa
Created October 20, 2014 12:39
AMI CoreShowChannels
# active call from 50 -> 49
Action: CoreShowChannels
Response: Success
EventList: start
Message: Channels will follow
Event: CoreShowChannel
Channel: SIP/49-1-00000011
@clue
clue / gist:76936f29984dc79f1fa0
Created October 20, 2014 12:39
AMI invalid action
Action: pong
Response: Error
Message: Invalid/unknown command: pong. Use Action: ListCommands to show available commands.
Action:ping
Response: Success
Ping: Pong
Timestamp: 1403277378.612099
@clue
clue / build.sh
Created October 20, 2014 18:15
psocksd.deb
sudo apt-get install rubygems
sudo gem install fpm
sudo apt-get install wget
wget http://lueck.tv/psocksd/psocksd.phar
chmod 755 psocksd.phar
fpm -s dir -t deb -n psocksd -v 0.3.1 -a all -d 'php5-cli > 5.3' --license MIT ./psocksd.phar=/usr/bin/psocksd
dpkg -c psocksd_0.3.1_all.deb
sudo dpkg -i psocksd_0.3.1_all.deb