Skip to content

Instantly share code, notes, and snippets.

function get_fd_count() {
local fds
cd /proc/$$/fd; fds=( * ) # avoid a StackOverflow source colorizer bug
echo "${#fds[@]}"
}
function fd_leak_func() {
while : ; do
echo ">> Current FDs: $(get_fd_count)"
read retval new_state < <(set +e; new_state=$(echo foo); retval=$?; printf "%d %s\n" $retval $new_state)
altscreen on
attrcolor b ".I"
autodetach on
caption always "%?%F%{= Kk}%:%{=u kR}%? %h %-024=%{= Kk} %C%a %D %d %M %Y%{= db}"
defbce "on"
defflow off
defscrollback 10000
defutf8 on
escape ^``
hardstatus alwayslastline "%{= kR} %-Lw%{= Kk} %n%f %t %{-}%+Lw %=%{= dd}"
@charles-dyfis-net
charles-dyfis-net / hashlib.bash
Created October 20, 2010 17:35
rewriting ABS / TLDB hashlib to follow best practices
# http://tldp.org/LDP/abs/html/contributed-scripts.html#HASHLIB
# Hash function library
# Author: Mariusz Gniazdowski <mariusz.gn-at-gmail.com>
# Date: 2005-04-07
# Author: Charles Duffy <charles@dyfis.net>
# Date: 2010-10-21
# Functions making emulating hashes in Bash a little less painful.
;; running the following code
(System/setProperty "jclouds.endpoint.Walrus" "http://euca.local:8773/services/Walrus")
(System/setProperty "jclouds.endpoint" "http://euca.local:8773/services/Eucalyptus")
(use 'pallet.compute 'pallet.maven)
(pallet.compute/compute-service-from-settings)
;; ...given the following in ~/.m2/settings.xml /settings/profiles/profile[activation/activateByDefault='true']/properties
<pallet.compute.provider>eucalyptus</pallet.compute.provider>
Some Humor: I've been attending the USENIX NT and LISA NT (Large Installation Systems Administration for NT) conference in downtown Seattle this week.
One of those magical Microsoft moments(tm) happened yesterday and I thought that I'd share. Non-geeks may not find this funny at all, but those in geekdom (particularly UNIX geekdom) will appreciate it.
Greg Sullivan, a Microsoft product manager (henceforth MPM), was holding forth on a forthcoming product that will provide Unix style scripting and shell services on NT for compatibility and to leverage UNIX expertise that moves to the NT platform. The product suite includes the MKS (Mortise Kern Systems) windowing Korn shell, a windowing PERL, and lots of goodies like awk, sed and grep. It actually fills a nice niche for which other products (like the MKS suite) have either been too highly priced or not well enough integrated.
An older man, probably mid-50s, stands up in the back of the room and asserts that Microsoft could have done better with their choi
@charles-dyfis-net
charles-dyfis-net / gist:838337
Created February 22, 2011 07:35
ElasticSearch logstash river config via curl
curl -v -XPUT 'localhost:9200/_river/logstash/_meta' -d '{
"type" : "rabbitmq",
"rabbitmq" : {
"host" : "192.168.123.8",
"port" : 5672,
"user" : "logstash",
"pass" : "logstash",
"vhost" : "logstash",
"exchange" : "parsed_logs",
"exchange_type" : "fanout",
@charles-dyfis-net
charles-dyfis-net / nodejs.spec
Created March 1, 2011 12:15
node.js spec for CentOS 5
#node is an already known package. node.js have dot in name, so "nodejs"
#is a better name
#some ideas are taken from
#http://blog.fpmurphy.com/2010/12/node-js-and-npm-on-fedora-14.html
Name: nodejs
Version: 0.4.0
Release: 0%{?dist}
Summary: JavaScript server-side network application development
Group: Development/Languages/Other
License: MIT
@charles-dyfis-net
charles-dyfis-net / parse-certs
Created June 23, 2011 19:34
Mozilla certdata.txt -> ca-bundle.crt parser
#!/bin/bash
#
# Parse Mozilla's certdata.txt and extract CA Root Certificates into PEM
# format.
#
# Based on http://curl.haxx.se/mail/lib-2004-07/0134.html; cleaned up to
# follow fewer worst practices for bash :)
#
# certdata.txt can be found in Mozilla's source tree:
# /mozilla/security/nss/lib/ckfw/builtins/certdata.txt
#!/bin/bash
while read -r diff
do
echo "$diff"
done < <(comm -12 <(sort db) <(sort dbnew)))
@charles-dyfis-net
charles-dyfis-net / gist:1069905
Created July 7, 2011 16:26
hashing the certificates in a bundle
reading=0
while read; do
if [[ $REPLY = *BEGIN* ]]; then
current_cert=""
reading=1
fi
if (( reading )) ; then
current_cert+="$REPLY"$'\n'
fi