Skip to content

Instantly share code, notes, and snippets.

@mike-bourgeous
mike-bourgeous / swap_stderr.sh
Created October 23, 2016 00:45 — forked from nitrogenlogic/00_swap_stderr_moved.md
Swap stdout and stderr, log stderr to a file (BASH)
#!/bin/bash
test() {
echo "Standard out"
echo "Standard error" >&2
}
tmpfile=`mktemp`
test 3>&1 4>&2 2>&3- 1>&4- | tee $tmpfile
cat $tmpfile
@mike-bourgeous
mike-bourgeous / posterous_import.rb
Created October 23, 2016 00:43 — forked from nitrogenlogic/00_posterous_import_moved.md
This quick and dirty script imports posts and images exported by the Posterous backup feature into Octopress. Requires the escape_utils and nokogiri gems. Doesn't import comments. See comments below the gist for more instructions.
#!/usr/bin/env ruby
# This quick and dirty script imports posts and images exported by the
# Posterous backup feature into Octopress. Requires the escape_utils and
# nokogiri gems. Doesn't import comments.
#
# Videos and images are copied into a post-specific image directory used
# by my customized Octopress setup. Encoded videos are downloaded from
# Posterous. Images will probably need to be compressed/optimized afterward.
#
# Links to other posts in the same import will try to be converted. You will
@mike-bourgeous
mike-bourgeous / mk_sfx.sh
Created October 23, 2016 00:40 — forked from nitrogenlogic/00_mk_sfx_moved.md
Quick-and-dirty script to create a quasi-self-extracting bzipped tar archive
#!/bin/bash
# Creates a base64-encoded self-extracting tar archive. The extracting system
# must have GNU tar, GNU coreutils (for base64), and bzip2 installed.
# Created June 2011 by Mike Bourgeous
# Released into the public domain, or if that is not possible, under CC0
function create_archive()
{
set -e
echo '#!/bin/sh'
@mike-bourgeous
mike-bourgeous / popen3_2007.c
Last active May 13, 2022 06:35 — forked from nitrogenlogic/00_popen3_moved.md
Two implementations of a popen3() function in POSIX/C providing stdin, stdout, and stderr (http://blog.mikebourgeous.com/2011/06/12/programmatic-process-control-in-c-popen3/)
/*
* This implementation of popen3() was created in 2007 for an experimental
* mpg123 frontend and is based on a popen2() snippet found online. This
* implementation may behave in unexpected ways if stdin/stdout/stderr have
* been closed or modified. No warranty of its correctness, security, or
* usability is given. My modifications are released into the public domain,
* but if used in an open source application, attribution would be appreciated.
*
* Mike Bourgeous
* https://github.com/mike-bourgeous