Skip to content

Instantly share code, notes, and snippets.

@giladdarshan
giladdarshan / macos_php_build.md
Last active December 29, 2024 04:52
Steps to build / compile PHP from source on macOS

The following steps will describe how to build PHP from source including PHP's Apache module as it is no longer part of macOS starting with macOS Monterey.
If this is for a development environment, you can simply install PHP with Homebrew using the command brew install php. This guide is for cases where you need a more portable PHP without heavily dependening on external libraries.

  1. Install Homebrew
  2. Install the following Homebrew packages
    • libxml2
    • libiconv
    • apr
    • apr-util
  3. Build Apache, if PHP's Apache module is not required, skip to step 4.
@sergeyklay
sergeyklay / CMakeLists.txt
Last active December 30, 2024 16:37
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
@gkhays
gkhays / DrawSineWave.html
Last active March 4, 2025 13:49
Oscillating sine wave, including the steps to figuring out how to plot a sine wave
<!DOCTYPE html>
<html>
<head>
<title>Sine Wave</title>
<script type="text/javascript">
function showAxes(ctx,axes) {
var width = ctx.canvas.width;
var height = ctx.canvas.height;
var xMin = 0;
@ankurk91
ankurk91 / install_lamp_ubuntu.sh
Last active January 23, 2025 04:13
Ubuntu 22/24 - PHP development (php 7.4 / 8.4, apache 2.4)
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Ubuntu Server
export DEBIAN_FRONTEND=noninteractive
echo -e "\e[96m Adding PPA \e[39m"
sudo add-apt-repository -y ppa:ondrej/apache2
@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 June 28, 2024 07:40
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(