Skip to content

Instantly share code, notes, and snippets.

View FooBarWidget's full-sized avatar

Hongli Lai FooBarWidget

View GitHub Profile
#!/usr/bin/env ruby
# This tool reads from STDIN and forwards all data to a file.
# It reopens the file upon receiving the SIGHUP signal.
require 'fcntl'
class Pipetool
def initialize(input, filename)
@input = input
@filename = filename
@event_pipe = IO.pipe
const HTTP_HEADERS_WITHOUT_PREFIX = {
'CONTENT_LENGTH': true,
'CONTENT_TYPE': true
};
function cgiKeyToHttpHeader(key) {
if (HTTP_HEADERS_WITHOUT_PREFIX[key]) {
return key.toLowerCase().replace(/_/g, '-');
} else if (key.match(/^HTTP_/)) {
return key.replace(/^HTTP_/, '').toLowerCase().replace(/_/g, '-');

Tony Arcieri (@bascule) asked: "@phusion_nl @dakami @tqbf the larger concern is how easily I can DoS it by running wrk on my laptop (same could be said of slowloris)"

In Phusion Passenger's design, all application processes are protected by the web server from Slowloris-like attacks. The buffering ensures that applications only receive a request when they're fully received from clients. It also ensures that applications are relieved from the request/response cycle as soon as they are done with the request, as opposed to when the client is done reading. In my tweet I said "You cannot DoS Passenger with Slowloris-like attacks". The more accurate, longer answer would be: susceptibility to Slowloris-like attacks depends on the web server. On Apache, you need to mitigate it with the proper Apache tools. You'll probably want to increase the number of Apache threads. On Nginx, you should be immune to Slowloris-like attacks thanks to its evented I/O architecture.

[EDIT] Note that the Slowloris protection has got no

<script src="http://handsontable.com/lib/jquery.min.js"></script>
<script src="http://handsontable.com/dist/jquery.handsontable.full.js"></script>
<link rel="stylesheet" media="screen" href="http://handsontable.com/dist/jquery.handsontable.full.css">
<div id="data_table" style="overflow: visible;" class="handsontable"></div>
<script>
$(document).ready(function() {
function createBigData() {
var rows = []
, i
[1123282.325396] CPU 1
esp4
xfrm4_mode_transport
deflate
ctr
twofish_generic
twofish_x86_64_3way
twofish_x86_64
twofish_common
camellia
@FooBarWidget
FooBarWidget / vmware-tools-dkms.sh
Last active December 19, 2015 16:29
Fix compatibility with kernel 3.8.0
#!/bin/bash
# Automatic install and configure VMware Tools using DKMS
# dkms.conf is an modified version of open-vm-tools' dkms.conf
#
# Idea for this script is from http://www.l4l.be/docs/virt/openvmtools_ubuntu810.php
#
# See also:
# http://runesk.blogspot.nl/2009/03/vmware-tools-and-dkms.html
# https://aur.archlinux.org/packages/vmware-modules-dkms/
#
[hongli@Asuna rvm-site (master)]$ ps auxw | grep ruby
hongli 26161 0.4 0.4 2484792 33372 s000 S+ 5:26PM 0:01.59 /Users/hongli/.rvm/gems/ruby-2.0.0-p195/bin/nanoc
hongli 26304 0.0 0.0 2432768 600 s001 R+ 5:26PM 0:00.00 grep ruby
[hongli@Asuna rvm-site (master)]$ gdb
GNU gdb 6.3.50-20050815 (Apple version gdb-1824) (Wed Feb 6 22:51:23 UTC 2013)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
[hongli@Asuna rvm-site (master)]$ bundle exec nanoc autocompile
Running on http://0.0.0.0:3000/
[2013-05-31 17:29:15] INFO WEBrick 1.3.1
[2013-05-31 17:29:15] INFO ruby 2.0.0 (2013-05-14) [x86_64-darwin12.3.0]
[2013-05-31 17:29:15] INFO WEBrick::HTTPServer#start: pid=26502 port=3000
(at this point, I access port 3000, and then...)
Trace/BPT trap: 5
[ pid=14408, timestamp=1369356349 ] Process aborted! signo=SIGABRT(6), reason=SI_TKILL, signal sent by PID 14408 with UID 0, si_addr=0x3848, randomSeed=1369356114
[ pid=14408 ] Crash log dumped to /var/tmp/passenger-crash-log.1369356349
[ pid=14408 ] Date, uname and ulimits:
Thu May 23 20:45:49 EDT 2013
Linux 2.6.16.33-xenU #2 SMP Wed Aug 15 17:27:36 SAST 2007 x86_64 x86_64
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 122944
Assertion failed! ext/common/MultiLibeio.cpp:82: int Passenger::dispatch(eio_req*): data->libev != __null
[ pid=3026, timestamp=1369288654 ] Process aborted! signo=SIGABRT(6), reason=SI_TKILL, signal sent by PID 3026 with UID 0, si_addr=0xac2, randomSeed=1369285932
[ pid=3026 ] Crash log dumped to /var/tmp/passenger-crash-log.1369288654
[ pid=3026 ] Date, uname and ulimits:
Wed May 22 22:57:34 PDT 2013
Linux 3.2.0-43-virtual #68-Ubuntu SMP Wed May 15 03:52:58 UTC 2013 x86_64 x86_64
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) unlimited
stack(kbytes) 8192