Skip to content

Instantly share code, notes, and snippets.

@Stantheman
Stantheman / apache_directory_size.sh
Created March 31, 2012 17:08
One-Liner to get approximate size of remote Apache directory listing using wget and perl
wget -r -nd -np --spider http://URL_GOES_HERE 2>&1 | perl -ne '$size += $1 if $_ =~ m/^Length: (\d+)/; END{print $size . "\n";}'
@adsr
adsr / foo.c
Last active September 11, 2018 21:35
// gcc -g -shared $(php-config --includes) -L$(php-config --prefix)/lib -lphp7 -o reopcode.so -fPIC reopcode.c
// sudo ./inject -p $(pgrep -n php) reopcode.so
#include <php.h>
#include <zend_API.h>
#include <zend_vm.h>
extern ZEND_API void (*zend_execute_ex)(zend_execute_data *execute_data);
static void (*orig_execute_ex)(zend_execute_data *execute_data);
@adsr
adsr / foo.diff
Created October 21, 2017 20:10
diff --git a/server/config.c b/server/config.c
index 7c7a1e0033..754152b86b 100644
--- a/server/config.c
+++ b/server/config.c
@@ -45,37 +45,42 @@
#include "http_protocol.h"
#include "http_core.h"
#include "http_log.h" /* for errors in parse_htaccess */
#include "http_request.h" /* for default_handler (see invoke_handler) */
#include "http_main.h"
@brendangregg
brendangregg / cpuunclaimed.py
Last active February 14, 2019 01:46
cpuunclaimed.py draft
#!/usr/bin/python
# @lint-avoid-python-3-compatibility-imports
#
# cpuunclaimed Sample CPU run queues and calculate unclaimed idle CPU.
# For Linux, uses BCC, eBPF.
#
# This samples the length of the run queues and determine when there are idle
# CPUs, yet queued threads waiting their turn. Report the amount of idle
# (yet unclaimed by waiting threads) CPU as a system-wide percentage.
#
@jpauli
jpauli / PHP useful valgrind suppressions
Created June 12, 2017 12:06
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
@brendangregg
brendangregg / chaintest.py
Last active May 26, 2023 09:55
chaintest
#!/usr/bin/python
#
# chaintest Summarize off-CPU time by kernel stack + 2 waker stacks
# WORK IN PROGRESS. For Linux, uses BCC, eBPF.
#
# USAGE: chaintest [-h] [-u] [-p PID] [-i INTERVAL] [-T] [duration]
#
# PLEASE DO NOT RUN THIS IN PRODUCTION! This is a work in progress, intended to
# explore chain graphs on Linux, using eBPF capabilities from a particular
# kernel version (4.3ish). This tool will eventually get much better.
@csfrancis
csfrancis / gdb_ruby_backtrace.py
Last active May 29, 2023 05:31
Dump an MRI call stack from gdb
# Updated for Ruby 2.3
string_t = None
def get_rstring(addr):
s = addr.cast(string_t.pointer())
if s['basic']['flags'] & (1 << 13):
return s['as']['heap']['ptr'].string()
else:
return s['as']['ary'].string()
@localh0t
localh0t / introspection_urlencoded.txt
Last active November 20, 2023 23:49
Introspection query from GraphQL-JS (URL-encoded)
%0A%20%20query%20IntrospectionQuery%20%7B%0A%20%20%20%20__schema%20%7B%0A%20%20%20%20%20%20queryType%20%7B%20name%20%7D%0A%20%20%20%20%20%20mutationType%20%7B%20name%20%7D%0A%20%20%20%20%20%20subscriptionType%20%7B%20name%20%7D%0A%20%20%20%20%20%20types%20%7B%0A%20%20%20%20%20%20%20%20...FullType%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20directives%20%7B%0A%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20description%0A%20%20%20%20%20%20%20%20locations%0A%20%20%20%20%20%20%20%20args%20%7B%0A%20%20%20%20%20%20%20%20%20%20...InputValue%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%0A%20%20fragment%20FullType%20on%20__Type%20%7B%0A%20%20%20%20kind%0A%20%20%20%20name%0A%20%20%20%20description%0A%20%20%20%20fields(includeDeprecated%3A%20true)%20%7B%0A%20%20%20%20%20%20name%0A%20%20%20%20%20%20description%0A%20%20%20%20%20%20args%20%7B%0A%20%20%20%20%20%20%20%20...InputValue%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20type%20%7B%0A%20%20%20%20%20%20%20%20...TypeRef%0A
@bobrik
bobrik / README.md
Last active January 19, 2024 08:45
CFS hiccups
@ragingwind
ragingwind / Backend Architectures Keywords and References.md
Last active April 17, 2024 10:51
Backend Architectures Keywords and References