Skip to content

Instantly share code, notes, and snippets.

View mattconnolly's full-sized avatar

Matt Connolly mattconnolly

View GitHub Profile
@mattconnolly
mattconnolly / gem-with-git-submodules.gemspec
Last active December 25, 2022 03:11
Gem Spec support for git submodules inside a gem.
Gem::Specification.new do |s|
# normal spec stuff above
s.files = `git ls-files`.split("\n")
# get an array of submodule dirs by executing 'pwd' inside each submodule
gem_dir = File.expand_path(File.dirname(__FILE__)) + "/"
`git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
Dir.chdir(submodule_path) do
submodule_relative_path = submodule_path.sub gem_dir, ""
# issue git ls-files in submodule's directory and
@mattconnolly
mattconnolly / gist:5737555
Created June 9, 2013 03:52
gdb backtrace of crash in czmq self test.
Core was generated by `/home/admin/czmq/src/.libs/czmq_selftest'.
Program terminated with signal 9, Killed.
#0 0xfffffd7fff273d9a in __pollsys () from /lib/64/libc.so.1
(gdb) bt
#0 0xfffffd7fff273d9a in __pollsys () from /lib/64/libc.so.1
#1 0xfffffd7fff25e585 in _pollsys () from /lib/64/libc.so.1
#2 0xfffffd7fff20a0d6 in poll () from /lib/64/libc.so.1
#3 0xfffffd7feeee1577 in zmq::signaler_t::wait (this=<optimized out>, timeout_=<optimized out>) at signaler.cpp:145
#4 0xfffffd7feeed621a in zmq::mailbox_t::recv (this=0x42a428, cmd_=0xfffffd7fffdff630, timeout_=<optimized out>)
at mailbox.cpp:74
@mattconnolly
mattconnolly / gist:5678362
Last active December 17, 2015 21:59
Cut down piece of code to scan for interfaces on SmartOS. Very basic at this stage. Based on code from samba: http://ftp.samba.org/pub/unpacked/ctdb/lib/replace/getifaddrs.c
/* this works for Linux 2.2, Solaris 2.5, SunOS4, HPUX 10.20, OSF1
* V4.0, Ultrix 4.4, SCO Unix 3.2, IRIX 6.4 and FreeBSD 3.2.
*
* It probably also works on any BSD style system. */
int max_interfaces=8;
int scan_interfaces()
{
struct ifconf ifc;
char buff[8192];
@mattconnolly
mattconnolly / gist:5669500
Created May 29, 2013 11:02
layout method to distribute subviews with even spaces between them. Simple task to achieve. Ridonkulously difficult with auto layout.
- (void)layoutSubviews
{
[super layoutSubviews];
CGRect bounds = self.bounds;
CGRect rect;
CGFloat usedHeight = 0;
int numViewsPlusOne = 1;
NSArray* viewsSortedByVerticalPosition = [self.subviews sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
@mattconnolly
mattconnolly / gist:5411998
Last active December 16, 2015 09:19
Attempting to build ruby-2.0.0 in SmartOS
[admin@test1 ~]$ openssl md5 ruby-2.0.0-p0.tar.gz
MD5(ruby-2.0.0-p0.tar.gz)= 50d307c4dc9297ae59952527be4e755d
[admin@test1 ~]$ pkgin list
autoconf-2.69nb1 Generates automatic source code configuration scripts
automake-1.12.6 GNU Standards-compliant Makefile generator
binutils-2.22nb1 GNU binary utilities
bison-2.7 GNU yacc(1) replacement
bmake-20110606 Portable (autoconf) version of NetBSD 'make' utility
bootstrap-mk-files-20120415 *.mk files for the bootstrap bmake utility
build-essential-1.0 Meta-package for essential build utilities
@mattconnolly
mattconnolly / pkgin-ls-output
Created April 15, 2013 06:09
`pkgin ls` output
[admin@rvm ~]$ pkgin ls
autoconf-2.69nb1 Generates automatic source code configuration scripts
automake-1.12.6 GNU Standards-compliant Makefile generator
bash-4.2nb2 The GNU Bourne Again Shell
binutils-2.22nb1 GNU binary utilities
bison-2.7 GNU yacc(1) replacement
bmake-20110606 Portable (autoconf) version of NetBSD 'make' utility
bootstrap-mk-files-20120415 *.mk files for the bootstrap bmake utility
bzip2-1.0.6 Block-sorting file compressor
changepass-1.3.3 Simple tool to set user passwords non-interactively
@mattconnolly
mattconnolly / gist:5354171
Created April 10, 2013 12:25
Difference between compiling netatalk in 2 zones.
--- netatalk-netatalk.txt 2013-04-10 21:06:48.000000000 +1000
+++ netatalk-vault-admin.txt 2013-04-10 21:15:42.000000000 +1000
@@ -1,4 +1,4 @@
-[admin@netatalk ~/netatalk-3.0.3]$ ./configure --prefix=/opt/local --with-init-style=solaris --with-init-dir=/var/svc/manifest/network/ --with-bdb=/opt/local && make
+[admin@vault ~/netatalk-3.0.3]$ ./configure --prefix=/opt/local --with-init-style=solaris --with-init-dir=/var/svc/manifest/network/ --with-bdb=/opt/local && make
checking build system type... x86_64-pc-solaris2.11
checking host system type... x86_64-pc-solaris2.11
checking target system type... x86_64-pc-solaris2.11
@@ -202,7 +202,8 @@
checking rpcsvc/rquota.h presence... yes
@mattconnolly
mattconnolly / gist:5298331
Created April 3, 2013 03:54
Amazon create AMI durations API call durations
Done, Database read lock held for 9.728 seconds
Done, Database read lock held for 2.599 seconds
Done, Database read lock held for 8.635 seconds
Done, Database read lock held for 3.085 seconds
Done, Database read lock held for 2.468 seconds
Done, Database read lock held for 96.438 seconds
Done, Database read lock held for 3.439 seconds
Done, Database read lock held for 17.616 seconds
Done, Database read lock held for 181.520 seconds
Done, Database read lock held for 15.200 seconds
@mattconnolly
mattconnolly / netatalk 3.0.3 build output
Created March 26, 2013 11:22
Configure and make output for netatalk 3.0.3 on SmartOS
matt@vault:~/netatalk/netatalk-3.0.3$ ./configure --with-bdb=/opt/local --with-init-style=solaris --with-init-dir=/var/svc/manifest/network/ --prefix=/opt/local
checking build system type... x86_64-pc-solaris2.11
checking host system type... x86_64-pc-solaris2.11
checking target system type... x86_64-pc-solaris2.11
checking for a BSD-compatible install... /opt/local/bin/ginstall -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /opt/local/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... yes
diff --git a/distrib/initscripts/Makefile.am b/distrib/initscripts/Makefile.am
index 5bdf951..bee3677 100644
--- a/distrib/initscripts/Makefile.am
+++ b/distrib/initscripts/Makefile.am
@@ -140,7 +140,7 @@ endif
if USE_SOLARIS
-servicedir = /lib/svc/manifest/network/
+servicedir = /var/svc/manifest/network/