Skip to content

Instantly share code, notes, and snippets.

@jperras
jperras / programmer_prayer.txt
Created April 18, 2011 20:41
The programmer's prayer.
Our root,
who art in Unix,
hallowed be thy shell.
Thy kernel come.
Thy commands be run
@localhost as they are in iNet.
Give us this day our daily updates,
And forgive us for our four-oh-threes,
as we forgive those who 403 against us.
And lead us not into segfaults,
@ichikaway
ichikaway / gist:1172839
Created August 26, 2011 06:39
protection of DOS attack
@ichikaway
ichikaway / gist:3291004
Created August 8, 2012 00:48
put current branch name on input cursor(need bash version 4)
bind -x '"\C-o": READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}
`git symbolic-ref HEAD | cut -d/ -f 3` ${READLINE_LINE:${READLINE_POINT}}"'
@predominant
predominant / ubuntu-1104-nginx-base.sh
Created October 5, 2011 15:19
Install Ubuntu 11.04 Nginx based web server with PHP-FPM, MySQL and MongoDB
#!/bin/bash
###
#
# Copyright (c) 2011 Cake Development Corporation (http://cakedc.com)
#
# Ubuntu 11.04 based web server installation script
# Run this by executing the following from a fresh install of Ubuntu 11.04 server:
#
# bash -c "$(curl -fsSL https://raw.github.com/gist/1264701)" <mysqlPassword>
@dogmatic69
dogmatic69 / bashrc.sh
Created October 19, 2010 18:27
make git prompt more useful
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
@jippi
jippi / Makefile
Last active October 12, 2017 07:52
CakePHP inside a Phar file. NOTE: Change "ROOT" constant in paths.php to "."
SHELL := /bin/bash
.PHONY: phar clean help
.DEFAULT_GOAL := help
phar: ## Build a phar file
mkdir -p dist/
rm -f dist/bownty-infra.phar
php build.php
chmod 0775 dist/bownty-infra.phar
@felixge
felixge / command.sh
Created October 29, 2011 13:43
Bash stuff for fighting a weak DOS attack
# Here a few bash one-liners that helped me analyze / fight a weak DOS attack against debuggable.com. Mostly for future reference.
# The attacker was opening lots of tcp connections without sending data, I believe it's called a SYN flood, see: http://tools.ietf.org/html/rfc4987#section-3.2
# Step 0: Check what is going on at port 80
$ netstat -tan | grep ':80 ' | awk '{print $6}' | sort | uniq -c
# Step 1: Increase the number of available fds
$ ulimit -n 32000
# Step 2: Restart your webserver, for me:
$ = jQuery
TIMEOUT = 20000
lastTime = (new Date()).getTime()
setInterval ->
currentTime = (new Date()).getTime()
# If timeout was paused (ignoring small
# variations) then trigger the 'wake' event
if currentTime > (lastTime + TIMEOUT + 2000)

Don't Buy the Snake Oil of Beamr Video

You might have heard of Beamr Video, and their impressive claims about reducing video bitrates by "up to 4x, without losing quality". Sounds too good to be true? Well, as a matter of fact, it is.

The Example Videos

The four example videos that Beamr has on their site use very high bitrates - 40-50 Mbps for 1080p video. These are the kind of bitrates you find on Blu-ray discs, whereas with something like Netflix's "SuperHD" you'd only get around ~5.6 Mbps (5800 kbps) 1080p video, and with 720p Netflix video the bitrate is only around ~3.5 Mbps (3600 kbps). If you have watched online streams like these, you'll probably know that they look quite decent. Now, if you look at the Beamr Video examples, you'll notice that even for their "reduced" clips, the bitrates are still around 9 Mbps minimum, and average as high as ~30 Mbps.

At this point, you can probably see the trick that Beamr is trying to pull

@barraponto
barraponto / git-submodule-rm.sh
Created April 25, 2012 16:36
git submodule-rm
#!/bin/bash
function actual_path() {
if [ [ -z "$1" ] -a [ -d $1 ] ]; then
echo $(cd $1 && test `pwd` = `pwd -P`)
return 0
else
return 1
fi
}