Skip to content

Instantly share code, notes, and snippets.

View WoZ's full-sized avatar

Dmitry Menshikov WoZ

View GitHub Profile
@WoZ
WoZ / README.md
Last active May 17, 2024 10:29
PHP-FPM with debug mode build instructions on top of docker-php repository

Intro

This tutorial helps to build your own version of the official php docker image with enabled debug options. Additionaly, this tutorial covers the steps to manualy patch php sources and manually rebuild it inside the container based on php official docker image.

Building php docker image with debug enabled

Starting from Dec 2023, building tools used to build official php docker image received support of DOCKER_PHP_ENABLE_DEBUG field. So, now it's pretty easy to build needed php version with --enable-debug flag.

Steps:

  1. Clone docker-library/php repository to docker-library-php folder
@WoZ
WoZ / no_keepalive_test.js
Created February 26, 2020 06:28
No KeepAlive test stand
const url = process.argv[2];
const concurrency = process.argv[3] === undefined ? 1 : parseInt(process.argv[3]);
const requestInterval = process.argv[4] === undefined ? 10000 : parseInt(process.argv[4]);
if (url === undefined || isNaN(concurrency) || isNaN(requestInterval)) {
console.log('Usage: node no_keepalive_test.js http://google.com/ 10 10000');
console.log('Where: 2nd - URL');
console.log(' 3rd - amount of concurrent connections (default is 1)');
console.log(' 4rd - interval between sequential requests');
process.exit();
@WoZ
WoZ / keepalive_test.js
Created February 23, 2020 14:52
KeepAlive test stand
const url = process.argv[2];
const concurrency = process.argv[3] === undefined ? 1 : parseInt(process.argv[3]);
const requestInterval = process.argv[4] === undefined ? 10000 : parseInt(process.argv[4]);
if (url === undefined || isNaN(concurrency) || isNaN(requestInterval)) {
console.log('Usage: node keepalive_test.js http://google.com/ 10 10000');
console.log('Where: 2nd - URL');
console.log(' 3rd - amount of concurrent connections (default is 1)');
console.log(' 4rd - interval between sequential requests');
process.exit();
@WoZ
WoZ / event_emitter_setImmediate_example.js
Created July 1, 2019 07:44
event_emitter_setImmediate_example.js
const {EventEmitter} = require('events');
const ee = new EventEmitter();
function log(...args) {
console.log(Date.now() / 1000, ...args);
}
function blockingOperation() {
log('-- Blocking operation has started');
@WoZ
WoZ / promise_executor_error_handling.js
Last active July 1, 2019 07:04
promise_executor_error_handling.js
setTimeout(() => { process.exit(); }, 200);
function f() {
try {
return new Promise((resolve, reject) => {
throw new Error('Error: Threw right in the executor');
});
} catch (err) {
console.log('Error caught in f()', err);
}
@WoZ
WoZ / test_message_loss_2.js
Created June 21, 2019 15:18
Advanced example of a data loss
const cluster = require('cluster');
async function waitForMessage(child) {
return new Promise(resolve => {
child.once('message', msg => {
console.log('Master. waitForMessage. Message is received', msg);
return resolve();
});
});
}
@WoZ
WoZ / test_message_loss_1.js
Last active June 21, 2019 15:12
Simplified example of a data loss
const {EventEmitter} = require('events');
const ee = new EventEmitter();
function waitForMessage() {
return new Promise(resolve => {
ee.once('message', msg => {
console.log('waitForMessage. Message is received', msg);
resolve();
console.log('waitForMessage. Ooops, resolve will run in microtask. not immediately');
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
int main(int argc, char *argv[])
{
struct addrinfo hints, *res, *p;
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
int main(int argc, char *argv[])
{
struct addrinfo hints, *res, *p;
#include <arpa/inet.h>
#include <net/if.h>
#include <ifaddrs.h>
#include <netdb.h>
#include <stdio.h>
int main(int argc, char* argv[], char* envp[]) {
struct ifaddrs *ifa=NULL,*ifEntry=NULL;
void *addPtr = NULL;
int rc = 0;