Skip to content

Instantly share code, notes, and snippets.

@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 / EC2-Describe-IAM-policy.json
Created Jan 30, 2015
Get an Amazon Elastic Beanstalk environment's name from inside one of its instances
View EC2-Describe-IAM-policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ec2:Describe*"
],
"Effect": "Allow",
"Resource": "*"
}
@SteelPangolin
SteelPangolin / Main.hs
Created Jan 20, 2015
Install Mac version of UT2004 from PC discs and Mac demo
View Main.hs
module Main where
{-
Utility to automatically install and patch the Mac OS X version
of Unreal Tournament 2004 from the Mac demo and patcher
and PC installation disc images and CD key.
Can automatically download the demo and patcher.
see: http://lowetechlabs.com/UT2004-WIN2OSX/
see: http://forums.macnn.com/showthread.php?t=292620
@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 / lsflags.c
Created Oct 2, 2012
lsflags: complementary utility to chflags. List flags for Mac OS X files and folders.
View lsflags.c
// compile with gcc -std=c99 -Wall lsflags.c -o lsflags
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/stat.h>
@SteelPangolin
SteelPangolin / mkdtemp.php
Created Nov 29, 2011
fake mkdtemp() for PHP
View mkdtemp.php
<?php
/**
* Create a directory in the system temp directory with a hard-to-predict name.
* Does not have the guarantees of the actual BSD libc function or Python tempfile function.
* @param string $suffix Append to the new directory's name
* @param string $prefix Prepend to the new directory's name
* @return string The path of the new directory.
*/
function mkdtemp($suffix = '', $prefix = 'tmp')
@SteelPangolin
SteelPangolin / rmtree.php
Created Nov 30, 2011
shutil.rmtree for PHP
View rmtree.php
<?php
/**
* Delete a file or directory recursively.
* @param string $path
*/
function rmtree($path)
{
if (is_dir($path))
{
@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
You can’t perform that action at this time.