Skip to content

Instantly share code, notes, and snippets.

View michael-grunder's full-sized avatar
💭
Testing in production

Michael Grunder michael-grunder

💭
Testing in production
View GitHub Profile
@michael-grunder
michael-grunder / bind-to-device.c
Created September 7, 2022 21:28
Hiredis SO_BINDTODEVICE example.
#include "hiredis.h"
#include <assert.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <linux/if.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
char device[IFNAMSIZ];
@michael-grunder
michael-grunder / phpredis-command-adds.txt
Created July 26, 2022 17:50
When commands were added to PhpRedis (4.3.0 was released 2019-03-13)
637b1c4 1258108773 2009-11-13 TYPE
637b1c4 1258108773 2009-11-13 RPUSH
637b1c4 1258108773 2009-11-13 SADD
637b1c4 1258108773 2009-11-13 LPUSH
637b1c4 1258108773 2009-11-13 LPOP
637b1c4 1258108773 2009-11-13 EXISTS
637b1c4 1258108773 2009-11-13 PING
637b1c4 1258108773 2009-11-13 SREM
a2d436d 1258552009 2009-11-18 RPOP
9488119 1258553043 2009-11-18 SMOVE
@michael-grunder
michael-grunder / php8.1-valgrind.patch
Created June 28, 2022 04:25
Patch PHP 8.1 to revert the Valgrind change which causes crashes
From 6ff49450eef966153abda5522aec456dcd899b8c Mon Sep 17 00:00:00 2001
From: michael-grunder <[email protected]>
Date: Thu, 9 Jun 2022 10:13:42 -0700
Subject: [PATCH] Revert Valgrind commits
b3898e951
a0c44fbaf
---
Zend/zend_string.c | 72 +++++++++++++++++++++++++++++++++++++++-------
1 file changed, 61 insertions(+), 11 deletions(-)
@michael-grunder
michael-grunder / libuv-timeout.patch
Created December 22, 2021 20:39
Add a timeout to the libuv hiredis adapter
diff --git a/adapters/libuv.h b/adapters/libuv.h
index c120b1b..b0b9ed4 100644
--- a/adapters/libuv.h
+++ b/adapters/libuv.h
@@ -9,6 +9,7 @@
typedef struct redisLibuvEvents {
redisAsyncContext* context;
uv_poll_t handle;
+ uv_timer_t timer;
int events;
@michael-grunder
michael-grunder / example.c
Created September 22, 2021 17:48
Tiny example using libevent and hiredis
// cc -Wall -ggdb3 -O0 -o example example.c -lhiredis -levent -lpthread -levent_pthreads
#define _POSIX_C_SOURCE 200809L
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <pthread.h>
#include <hiredis/async.h>
#include <hiredis/adapters/libevent.h>
@michael-grunder
michael-grunder / redis-tcp-data.txt
Created May 11, 2021 21:32
Redis traffic captured with: sudo tcpflow -i any -c src port 6379
127.000.000.001.06379-127.000.000.001.43804: %7
$6
server
$5
redis
$7
version
$5
6.2.3
$5
@michael-grunder
michael-grunder / reproduce.c
Last active May 11, 2021 21:34
Code to reproduce embedded resp3 push replies
#include <stdio.h>
#include <assert.h>
#include <hiredis/hiredis.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
/*
* compile with:
* cc -oreproduce -g -ggdb reproduce.c -lhiredis
# Server
redis_version:6.2.3
redis_git_sha1:e90e5640
redis_git_dirty:0
redis_build_id:d26ed72d47fcc498
redis_mode:standalone
os:Linux 5.8.0-50-generic x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
@michael-grunder
michael-grunder / examples.txt
Created April 2, 2021 17:08
Install pecl yaml
#
# 1) One-liner assuming you installed libyaml via brew
#
echo $(brew --prefix libyaml)|sudo pecl install yaml
#
# 2) Pass --with-yaml directly to ./configure
#
@michael-grunder
michael-grunder / build-apcu.sh
Created April 1, 2021 18:59
Clone and build apcu, then output it's filetype
#!/bin/bash
set -e
git clone https://github.com/krakjoe/apcu && cd apcu
echo "ARCH: " $(arch)
phpize && ./configure && make
file .libs/apcu.so