Skip to content

Instantly share code, notes, and snippets.

@SteelPangolin
SteelPangolin / etc_init.d_foo
Last active January 20, 2016 19:51
Run socat as a SysV service to write TCP stream contents to a file
#!/bin/bash
### BEGIN INIT INFO
# Provides: foo
# Defalt-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Writes TCP on port 8725 to a file
### END INIT INFO
source /etc/rc.d/init.d/functions
@SteelPangolin
SteelPangolin / robbyrussell-hostname.zsh-theme
Created October 20, 2015 21:58
Tweak robbyrussell ZSH theme to prepend hostname
local hostname="%{$fg_bold[black]%}%m"
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)"
PROMPT='${hostname} ${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
@SteelPangolin
SteelPangolin / adblock-related-content.txt
Created July 20, 2015 20:48
Adblock filter list for "related content" garbage
@SteelPangolin
SteelPangolin / php-pecl-parsekit-1.3-php56-variadic-fix.patch
Created May 20, 2015 20:26
patch by @Hubbitus for Parsekit on PHP 5.6; see PHP bug #67854
diff -Naur php-pecl-parsekit-1.3.0.orig/parsekit-1.3.0/parsekit.c php-pecl-parsekit-1.3.0/parsekit-1.3.0/parsekit.c
--- php-pecl-parsekit-1.3.0.orig/parsekit-1.3.0/parsekit.c 2014-08-16 21:55:32.000000000 +0400
+++ php-pecl-parsekit-1.3.0/parsekit-1.3.0/parsekit.c 2014-08-18 12:50:05.377165855 +0400
@@ -300,7 +300,7 @@
}
add_assoc_long(return_value, "num_args", ops->num_args);
add_assoc_long(return_value, "required_num_args", ops->required_num_args);
- add_assoc_bool(return_value, "pass_rest_by_reference", ops->fn_flags & ZEND_ACC_PASS_REST_BY_REFERENCE);
+ add_assoc_bool(return_value, "pass_rest_by_reference", ops->fn_flags & ZEND_ACC_VARIADIC);
#!/usr/bin/env python
"""
Translate a CSV document with a header to a YAML document that is a list of maps.
Uses constant memory and keeps field names in the original order.
"""
import sys
import csv
import yaml # requires PyYAML
@SteelPangolin
SteelPangolin / xcom.py
Created May 12, 2015 04:51
Generate a random X-COM mission name.
#!/usr/bin/env python3
"""
Generate a random X-COM mission name.
See http://xcom.wikia.com/wiki/Missions_%28XCOM:_Enemy_Unknown%29
and http://kotaku.com/5916411/why-all-of-xcom-enemy-unknowns-missions-sound-like-1980s-heavy-metal-albums
"""
from random import choice
prefixes = [
@SteelPangolin
SteelPangolin / README.md
Created April 7, 2015 19:17
Packer template for building a Debian-based AMI suitable for developing and running Python 3.4-based services

This is a Packer template for building a Debian-based AMI suitable for developing and running Python 3.4-based services. It uses a Debian 8 prerelease image as the base.

To build the AMI:

  • Install Packer.
  • Make sure your Amazon credentials are in ~/.aws/credentials.
  • If using an AWS region other than Oregon, change region and source_ami in packer-template.json.
  • Run packer build packer-template.json.
@SteelPangolin
SteelPangolin / pip-upgrade.sh
Created April 3, 2015 03:39
Upgrade all outdated packages managed by pip. Great for virtualenvs.
#!/bin/sh
pip list --outdated | cut -d ' ' -f 1 | xargs pip install -U
--- a/parsekit-1.3.0/parsekit.c
+++ b/parsekit-1.3.0/parsekit.c
@@ -78,18 +78,18 @@
#ifdef IS_CV
/* PHP >= 5.1 */
} else if (node->op_type == IS_CV) {
- add_assoc_long(return_value, "var", node->u.var);
- add_assoc_stringl(return_value, "varname", op_array->vars[node->u.var].name, op_array->vars[node->u.var].name_len, 1);
+ add_assoc_long(return_value, "var", node->u.op.var);
+ add_assoc_stringl(return_value, "varname", op_array->vars[node->u.op.var].name, op_array->vars[node->u.op.var].name_len, 1);