Skip to content

Instantly share code, notes, and snippets.

View bahamas10's full-sized avatar

Dave Eddy bahamas10

View GitHub Profile
@bahamas10
bahamas10 / throw.js
Created January 28, 2015 19:23
throw fun
// https://twitter.com/bahamas10_/status/545714690589200384
function add(x,y) {
throw x + y;
}
try {
add(2, 2);
} catch(sum) {
console.log(sum)
};
@bahamas10
bahamas10 / output.txt
Created January 30, 2015 19:18
manta sync reverse PoC
$ mmkdir ~~/stor/foo
$ echo foo | mput ~~/stor/foo/a
/bahamas10/stor/foo/a 4B
$ echo bar | mput ~~/stor/foo/b
/bahamas10/stor/foo/b 4B
$ echo baz | mput ~~/stor/foo/c
/bahamas10/stor/foo/c 4B
$ mkdir foo
$ ./manta-sync -v -r ~~/stor/foo ./foo
sourcedir: <MantaFile: /bahamas10/stor/foo>
@bahamas10
bahamas10 / foo.js
Created February 6, 2015 16:57
nodejs mkdir mode
> fs.mkdirSync('test-dir', 0777)
undefined
> (fs.statSync('test-dir').mode & 0777).toString(8)
'755'
> process.version
'v0.10.33'
@bahamas10
bahamas10 / README.md
Last active August 29, 2015 14:15
chef 12 vs 11 node attributes

Attributes are set differently from Chef 11 to Chef 12.

Example Cookbook

cookbooks/test/recipes/default.rb

node.set['foo'] = JSON.parse('[{"bar": true}]')
p node[:foo].first.class
@bahamas10
bahamas10 / compile.md
Created February 25, 2015 20:15
haproxy

I compiled openssl 1.0.1l to $LIBSSLBUILD before hand use the directions in the haproxy readme... then

$ make TARGET=solaris USE_OPENSSL=yes USE_STATIC_PCRE=1 ADDINC=-I$LIBSSLBUILD/include ADDLIB="-L$LIBSSLBUILD/lib -ldl" clean all
...
$ ./haproxy -vv | grep OpenSSL | head -2
Built with OpenSSL version : OpenSSL 1.0.1l 15 Jan 2015
Running on OpenSSL version : OpenSSL 1.0.1e 11 Feb 2013
@bahamas10
bahamas10 / README.md
Last active August 29, 2015 14:16
compile haproxy with static ssl on smartos
rm -rf /var/tmp/ssl
mkdir -p /var/tmp/ssl

mkdir ~/src
cd ~/src

wget https://www.openssl.org/source/openssl-1.0.1l.tar.gz
wget http://www.haproxy.org/download/1.5/src/haproxy-1.5.11.tar.gz
@bahamas10
bahamas10 / README.md
Last active August 29, 2015 14:16
pfiles slow on sockets (v2)

Illumos pfiles

pfiles(1) is slow when gathering information about sockets.

This patch (https://www.illumos.org/issues/5397) sped it up immensely, but it is still slower than it should be. Looking at the time spent in syscalls when pfiles(1) is run from the patch we can see this:

  pwrite                                                    355720528
  write                                                     842822775
@bahamas10
bahamas10 / quine.bash
Created March 3, 2015 07:38
bash quine
#!/usr/bin/env bash
s=(
'#!/usr/bin/env bash'
''
's=('
')'
''
'q=$(printf "\x27")'
'for ((i = 0; i < 3; i++ )); do'
@bahamas10
bahamas10 / quine.js
Created March 4, 2015 16:24
node quine
#!/usr/bin/env node
var util = require("util");
var source = [
'#!/usr/bin/env node',
'',
'var util = require("util");',
'',
'var source = [',
@bahamas10
bahamas10 / install.txt
Created March 9, 2015 15:25
install isolated ruby and chef on smartos
(as root)
mkdir ~/src
cd ~/src
# install ruby
wget http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.1.tar.gz
tar xf ruby-2.2.1.tar.gz
cd ruby-2.2.1
./configure --prefix=/opt/chef --with-opt-dir=/opt/local --enable-shared ac_cv_func_dl_iterate_phdr=no CFLAGS="-R -fPIC" rb_cv_have_signbit=no --disable-install-doc