This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This is an example of how to hook up evhttp with bufferevent_ssl | |
It just GETs an https URL given on the command-line and prints the response | |
body to stdout. | |
Actually, it also accepts plain http URLs to make it easy to compare http vs | |
https code paths. | |
Loosely based on le-proxy.c. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# replace binary with cat(1), | |
# so that if this program runs in pipe it will not fail the pipe | |
# | |
p open("/dev/null", 2) | |
p dup2($1, 1) | |
p dup2($1, 2) | |
p close($1) | |
p calloc(sizeof(char *), 2) | |
p strdup("/bin/cat") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# re-export bash settings into container from host | |
lxc.mount.entry = /etc/bash.bashrc etc/bash.bashrc none ro,bind,create=file 0 0 | |
lxc.mount.entry = /etc/bash.d etc/bash.d none ro,bind,create=dir 0 0 | |
lxc.mount.entry = /etc/bash_completion.d etc/bash_completion.d none ro,bind,create=dir 0 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# host: archlinux | |
# Distribution configuration | |
lxc.include = /usr/share/lxc/config/debian.common.conf | |
lxc.arch = x86_64 | |
# Container specific configuration | |
lxc.cgroup.cpuset.cpus = 0 | |
# Network configuration | |
lxc.network.type = veth | |
lxc.network.flags = up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [[ "$*" =~ "--output" ]]; then | |
prev=$# | |
let --prev | |
output="${@:$prev:1}" | |
url="${@:$#}" | |
# to fix vagrant download issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <event2/event.h> | |
#include <event2/bufferevent.h> | |
struct arg | |
{ | |
int i; | |
int *i_ptr; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
tr -cd 'a-z' < /dev/urandom | dd iflag=fullblock of=test bs=1M count=100 | |
tail -c+$((1 + 8192)) test | head -c100; echo | |
off=$(filefrag -v test | tail -n+4 | head -1 | awk '{print $4}' | tr -d .) | |
sudo dd iflag=direct if=/dev/sda1 bs=4K skip=$((off + 2)) count=1 2>/dev/null | head -c100; echo | |
sudo dd oflag=direct of=/dev/sda1 if=/dev/zero bs=4K seek=$((off + 2)) count=1 | |
tail -c+$((1 + 8192)) test | head -c100; echo | |
sudo dd iflag=direct if=/dev/sda1 bs=4K skip=$((off + 2)) count=1 2>/dev/null | head -c100; echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env awk | |
# strace -ttt parser (speed ~ 10MB/s) | |
function inc(pid, time, syscall) | |
{ | |
# per-thread elapsed | |
if (threads[pid]) { | |
e = time - threads[pid]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <assert.h> | |
#include <event2/event.h> | |
#include <event2/event_compat.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/libevent.c b/libevent.c | |
index 97e8210..467346f 100644 | |
--- a/libevent.c | |
+++ b/libevent.c | |
@@ -1392,6 +1392,8 @@ static PHP_MINIT_FUNCTION(libevent) | |
le_event = zend_register_list_destructors_ex(_php_event_dtor, NULL, "event", module_number); | |
le_bufferevent = zend_register_list_destructors_ex(_php_bufferevent_dtor, NULL, "buffer event", module_number); | |
+ event_init(); | |
+ |