Skip to content

Instantly share code, notes, and snippets.

mike-bourgeous / standalone_readpixels.c
Last active Jul 2, 2020
Linux and GLX example of fast glReadPixels with PBOs
View standalone_readpixels.c
* Minimal Linux- and GLX-specific example of using a pool of Pixel Buffer
* Objects to stream pixel data.
* This is a minimal test case for opening an OpenGL window with raw
* X11/Xlib/GLX, drawing a simple test image, and fast PBO-based streaming of
* image data to disk with glReadPixels().
* On an NVidia RTX2080 Super, on Ubuntu 20.04, saving to an SSD, this sustains
* 150+fps (peaking at 500+, hitting 900+ if only writing a single file instead
mike-bourgeous /
Created Oct 23, 2016 — forked from nitrogenlogic/
Swap stdout and stderr, log stderr to a file (BASH)
test() {
echo "Standard out"
echo "Standard error" >&2
test 3>&1 4>&2 2>&3- 1>&4- | tee $tmpfile
cat $tmpfile
mike-bourgeous / posterous_import.rb
Created Oct 23, 2016 — forked from nitrogenlogic/
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.
View posterous_import.rb
#!/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 /
Created Oct 23, 2016 — forked from nitrogenlogic/
Quick-and-dirty script to create a quasi-self-extracting bzipped tar archive
# 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 / popen3_2007.c
Last active May 29, 2019 — forked from nitrogenlogic/
Two implementations of a popen3() function in POSIX/C providing stdin, stdout, and stderr (
View popen3_2007.c
* 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
mike-bourgeous / oralaunch
Created Aug 16, 2016
Scripts to improve launching Oracle's sqlplus client (put these in ~/bin, call orasql)
View oralaunch
# Launches an application with the Oracle instant client environment set.
# Created by Mike Bourgeous,
export CLIENT_PATH=/usr/lib/oracle/11.2/client64/lib
export SQLPATH="$HOME/.oracle:$CLIENT_PATH"
export TNS_ADMIN="$HOME/.oracle"
export NLS_LANG="american_america.utf8"
mike-bourgeous / Basic_ruby_oracle_demo.rb
Last active Mar 25, 2020
Using the OCI8, Sequel, and ruby_plsql gems all together
View Basic_ruby_oracle_demo.rb
#!/usr/bin/env ruby
# Simplified demo showing the use of the Sequel gem, raw OCI8 connection, and
# ruby_plsql gem on a single connection. Uses undocumented yield behavior from
# Sequel, so might not work with different Sequel versions.
# by Mike Bourgeous
# These must be set before requiring oci8
ENV['NLS_LANG'] = 'american_america.utf8'
ENV['TNS_ADMIN'] = File.expand_path(File.dirname(__FILE__))
mike-bourgeous / quick_and_dangerous_struct.rb
Last active Aug 12, 2016
A toy version of OpenStruct, with no error checking
View quick_and_dangerous_struct.rb
# Faster than OpenStruct, but liable to get your box pwned.
class QuickAndDangerousStruct
def method_missing(name, *args)
send name, *args
def make_method(name)
name = name.to_s
base = name.end_with?('=') ? name[0..-2] : name
mike-bourgeous / gc_stat.rb
Last active Aug 4, 2016
Convenient way to get GC stats for a block of Ruby code.
View gc_stat.rb
def gc_stat
asym = :total_allocated_objects
fsym = :total_freed_objects
before = GC.stat
ba = before[asym]
bf = before[fsym]
puts "Before: alloc=#{ba} free=#{bf}"
You can’t perform that action at this time.