Skip to content

Instantly share code, notes, and snippets.

@nitrogenlogic
nitrogenlogic / 00_swap_stderr_moved.md
Last active October 23, 2016 00:46
Swap stdout and stderr, log stderr to a file (BASH)
@nitrogenlogic
nitrogenlogic / 00_posterous_import_moved.md
Last active October 23, 2016 00:43
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.
@nitrogenlogic
nitrogenlogic / simple_xap_parser.rb
Created July 12, 2012 14:42
Simplified parser for xAP messages
def self.simple_parse(data)
Hash[*data.split(/}\n?/).map {|v|
bl = v.split("\n{\n")
bl[1] = Hash[*bl[1].split("\n").map {|v2|
pair = v2.split(/[=!]/, 2)
pair[1] = [pair[1]].pack 'H*' if v2 =~ /^[^=!]+!/
pair
}.flatten!]
bl
}.flatten!(1)]
@nitrogenlogic
nitrogenlogic / async_sinatra_error_patch.rb
Created June 22, 2011 22:07
[non-functional] Monkey patch exception logging into async_sinatra (quick workaround)
# Monkey patch exception logging into async_sinatra
#
# This is a workaround for the lack of error handling/logging on asynchronous
# requests (e.g. aget, apost) when using async_sinatra 0.5.0, sinatra 1.2.6,
# thin 1.2.11, and rack 1.3.0.
#
# See http://stackoverflow.com/questions/6427033/how-do-i-log-asynchronous-thinsinatrarack-requests
module Sinatra::Async
alias :oldaroute :aroute
@nitrogenlogic
nitrogenlogic / 00_mk_sfx_moved.md
Last active October 23, 2016 00:41
Quick-and-dirty script to create a quasi-self-extracting bzipped tar archive
@nitrogenlogic
nitrogenlogic / 00_popen3_moved.md
Last active May 29, 2019 11:53
Two implementations of a popen3() function in POSIX/C providing stdin, stdout, and stderr