Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Lück clue

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

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.
View gist:11254932
$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)
View gist:4212c21860f4078a89dc
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
View EnterpriseApi.php
<?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 Aug 31, 2014
Reproduce SSL buffering issue
View ssl.php
<?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 / build.sh
Created Oct 20, 2014
psocksd.deb
View build.sh
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
@clue
clue / gist:4428883931c295ec82db
Created Oct 20, 2014
AMI command: sip show peers
View gist:4428883931c295ec82db
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
View gist:29f48b134f273efcfcfa
# active call from 50 -> 49
Action: CoreShowChannels
Response: Success
EventList: start
Message: Channels will follow
Event: CoreShowChannel
Channel: SIP/49-1-00000011
View gist:76936f29984dc79f1fa0
Action: pong
Response: Error
Message: Invalid/unknown command: pong. Use Action: ListCommands to show available commands.
View gist:366bf7fa98f99d3d466b
Action:ping
Response: Success
Ping: Pong
Timestamp: 1403277378.612099
You can’t perform that action at this time.