Skip to content

Instantly share code, notes, and snippets.

@sergeyklay
sergeyklay / CMakeLists.txt
Last active April 6, 2024 18:52
CMakeLists.txt for PHP-extension. This CMake file is just for syntax highlighting in CLion.
cmake_minimum_required(VERSION 3.5)
project(extname
VERSION 1.0.0
LANGUAGES C)
message(STATUS "Begin cmaking of PHP extension ...")
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING
@scr34m
scr34m / zeromq_wire_protocol.php
Last active July 6, 2019 20:57
raw zeromq wire protocol in php
<?php
// ZMTP/2.0 http://rfc.zeromq.org/spec:15
// ZMTP/1.0 http://rfc.zeromq.org/spec:13
$fp = fsockopen("127.0.0.1", 5559, $errno, $errstr, 1);
if (!$fp) {
return;
}
stream_set_timeout($fp, 0, 500);
@acidleaf
acidleaf / vec2.h
Last active December 18, 2023 19:45
C++ 2D Vector
/*
Copyright (c) 2020 Chan Jer Shyan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@ianbarber
ianbarber / simplepub.php
Created June 21, 2013 15:17
A noddy implementation of ZMTP 3.0 in PHP http://rfc.zeromq.org/spec:23
<?php
include_once "zmtp.php";
// This was connecting to a libzmq master based subscriber.
$host = "127.0.0.1";
$port = 4422;
// Connect and send null mechanism.
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$rc = socket_connect($socket, $host, $port);
@rcrowley
rcrowley / acknowledgment_test.go
Last active October 14, 2022 09:22
Benchmark of goroutine acknowledgment patterns
// Go encourages us to organize our code using goroutines and to use
// channels of channels to implement request-response semantics [1].
//
// I have encountered far more instances that require acknowledgment
// than fully-fledged respones so I became curious whether channels
// of channels were indeed the best implementation strategy.
//
// In summary, yes, they are. These benchmarks demonstrate that
// channels perform better than mutexes, that condition variables are
// still clumsy, and that preallocation is a huge win when and if you
@b00gizm
b00gizm / gist:1106905
Created July 26, 2011 14:33
Spawning node.js processes with PHP
<?php
class Foo
{
// ...
protected function spawnProcess()
{
if (!function_exists('proc_open')) {
throw new \RuntimeException(