Skip to content

Instantly share code, notes, and snippets.

@SteelPangolin
SteelPangolin / etc_init.d_foo
Last active Jan 20, 2016
Run socat as a SysV service to write TCP stream contents to a file
View etc_init.d_foo
#!/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 Oct 20, 2015
Tweak robbyrussell ZSH theme to prepend hostname
View robbyrussell-hostname.zsh-theme
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 Jul 20, 2015
Adblock filter list for "related content" garbage
View adblock-related-content.txt
@SteelPangolin
SteelPangolin / php-pecl-parsekit-1.3-php56-variadic-fix.patch
Created May 20, 2015
patch by @Hubbitus for Parsekit on PHP 5.6; see PHP bug #67854
View php-pecl-parsekit-1.3-php56-variadic-fix.patch
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);
View csv2yaml.py
#!/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
Generate a random X-COM mission name.
View xcom.py
#!/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 = [
View Exploring is never boring.md
@SteelPangolin
SteelPangolin / README.md
Created Apr 7, 2015
Packer template for building a Debian-based AMI suitable for developing and running Python 3.4-based services
View README.md

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 Apr 3, 2015
Upgrade all outdated packages managed by pip. Great for virtualenvs.
View pip-upgrade.sh
#!/bin/sh
pip list --outdated | cut -d ' ' -f 1 | xargs pip install -U
View parsekit
--- 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);
You can’t perform that action at this time.