Skip to content

Instantly share code, notes, and snippets.

Avatar
🐍

jpauli jpauli

🐍
View GitHub Profile
@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");
@jpauli
jpauli / optimized libc memcpy()
Created Jan 29, 2014
memcpy() with a sizeof(void *) size just nicely uses mov
View optimized libc memcpy()
160 char *str1 = "mystring";
7ffff6240c71: lea 0xf2(%rip),%rax # 0x7ffff6240d6a
7ffff6240c78: mov %rax,-0x8(%rbp)
161 char *str2 = NULL;
7ffff6240c7c: movq $0x0,-0x10(%rbp)
165 memcpy(&str2, &str1, sizeof(char *));
7ffff6240c84: mov -0x8(%rbp),%rax
7ffff6240c88: mov %rax,-0x10(%rbp)