Skip to content

Instantly share code, notes, and snippets.

jpauli jpauli

Block or report user

Report or block jpauli

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:dc0565bdbdd8edd9bf620332b206c4ba
<?php
function foo(object $o) : ?string
{
try {
return $o->bar();
} catch (Exception $e) {
error_log($e);
}
}
@jpauli
jpauli / gist:584c18affa9aa34e5f0011aa7fa1ea68
Created Oct 17, 2018
Warn about unreachable catch blocks
View gist:584c18affa9aa34e5f0011aa7fa1ea68
<?php
try {
$o->foo();
} catch (Exception $e) {
} catch (FooException $e) {
}
// Notice : Unreachable catch block "FooException" in file XXX at line YYYY
@jpauli
jpauli / gist:0d339973c244fc83248f67dc3b8f9d2f
Last active Apr 6, 2018
Update bind zones on public IP DHCP renew
View gist:0d339973c244fc83248f67dc3b8f9d2f
#!/home/doc/php/bin/php
<?php
$exit = 0;
$exit_signal = 0;
function fork()
{
$pid = pcntl_fork();
if ($pid < 0) {
@jpauli
jpauli / PHP useful valgrind suppressions
Created Jun 12, 2017
PHP useful valgrind suppressions
View PHP useful valgrind suppressions
{
<insert_a_suppression_name_here>
Memcheck:Leak
fun:malloc
fun:init_op_array
fun:compile_file
obj:*
...
fun:zend_execute_scripts
fun:php_execute_script
View gist:3eea2b4c2bfc835f86703107266527d8
<?php
namespace JPauli;
/**
* This is a simple web scrapper that helps dumping your (or someone's)
* steam screenshots, as Valve doesn't seem to care about providing an API
* for that purpose.
*
* If the screenshots are not public, you'll need to log into steam website
* and provide your cookie information for the API to be able to connect and
View slprintf() leak ?
==6700== 36 bytes in 1 blocks are still reachable in loss record 14 of 39
==6700== at 0x4C28C20: malloc (vg_replace_malloc.c:296)
==6700== by 0x9FC2DE: Balloc (zend_strtod.c:600)
==6700== by 0x9FC7EC: mult (zend_strtod.c:879)
==6700== by 0x9FCA7F: pow5mult (zend_strtod.c:1007)
==6700== by 0xA00836: zend_dtoa (zend_strtod.c:4178)
==6700== by 0x942CD1: __cvt (snprintf.c:96)
==6700== by 0x942E66: php_fcvt (snprintf.c:138)
==6700== by 0x943389: php_conv_fp (snprintf.c:389)
==6700== by 0x944DD3: format_converter (snprintf.c:1036)
View gist:85211102df1a17f22de5
<?php
class Foo
{
public function __invoke($arg)
{
yield $arg;
}
}
View php psig for Linux
#! /usr/bin/env php
<?php
if ($argc != 2) {
exit(sprintf("Usage : %s <pid>\n", $argv[0]));
}
if (!file_exists("/proc/1/status")) {
exit("/proc/1/status does not exist, what OS are you running ?\n");
@jpauli
jpauli / gist:69ff64a8425e8fd2e24b
Created Jul 1, 2014
PHP fast-cgi pool balancer management script
View gist:69ff64a8425e8fd2e24b
#!/bin/bash
pool1=pool_1
pool2=pool_2
port1=8031
port2=8032
nbport1=0
nbport2=0
@jpauli
jpauli / gist:8afec7c4fc2b38f8ff27
Created Jun 13, 2014
fallocate VS ftruncate demo
View gist:8afec7c4fc2b38f8ff27
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
if (argc != 3) {
printf("Usage: allocate <1:ftruncate, 2:fallocate> <size> \n");
You can’t perform that action at this time.