Skip to content

Instantly share code, notes, and snippets.

View mattconnolly's full-sized avatar

Matt Connolly mattconnolly

View GitHub Profile
@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 / 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:5963270
Last active December 19, 2015 13:38
rbczmq notes

Object Ownership:

CZMQ appears quite explicit about ownership of objects. For example:

  • zmsg_send will destroy the message when sent. This includes destroying any frames that are owned by the zmsg_t.
  • Calling zmsg_add means that the zmsg_t takes ownership of the zframe_t.

I was thinking about making this "ownership" concept an explicit state in the ruby wrappers. So:

  • zmq_message_wrapper would have a flag for "owning the message", which would be cleared when we send the message.
@mattconnolly
mattconnolly / gist:6097313
Created July 28, 2013 03:58
Adding a zfs dataset to a SmartOS zone. Seems there's no vmadm api for this, but you can do it with zonecfg:
# vmadm halt <uuid>
# zonecfg -z <uuid>
zonecfg:uuid> add dataset
zonecfg:uuid:dataset> set name=<zfs/path>
zonecfg:uuid:dataset> end
zonecfg:uuid> commit
zonecfg:uuid> exit
# zfs set mountpoint=legacy <zfs/path>
# vmadm boot <uuid>
@mattconnolly
mattconnolly / gist:6127693
Created August 1, 2013 01:14
Using zonecfg to fix missing DNS resolvers in a SmartOS zone.
# zonecfg -z <uuid>
zonecfg:uuid> add attr
zonecfg:uuid:attr> set name=resolvers
zonecfg:uuid:attr> set type=string
zonecfg:uuid:attr> set value=8.8.8.8,8.8.4.4
zonecfg:uuid:attr> end
zonecfg:uuid> verify
zonecfg:uuid> commit
zonecfg:uuid> exit
# vmadm reboot <uuid>
@mattconnolly
mattconnolly / install.sh
Last active April 4, 2016 04:19 — forked from jim80net/install.sh
Pseudo script for installing Jenkins CI on Smart OS. SMF service manifest file included.
#!/bin/pseudo-bash
# Read through this and modify to taste.
# Tested on:
# image_uuid: bad2face-8738-11e2-ac72-0378d02f84de
# smartos base64 1.9.0
#
# jenkins is run as the "admin" user, with its home directory set to /home/admin/jenkins
mkdir ~/jenkins
@mattconnolly
mattconnolly / gist:6397688
Created August 31, 2013 11:32
zeromq forking - child process terminates inherited zeromq context
//
// main.c
// zmq-test1
//
// Created by Matt Connolly on 8/08/2013.
//
//#include <ZeroMQ/zmq.h>
#include <czmq.h>
@mattconnolly
mattconnolly / gist:6435054
Created September 4, 2013 09:59
vagrant file for SmartOS
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
@mattconnolly
mattconnolly / gist:6444557
Created September 5, 2013 00:27
Using zonecfg to set qemu_extra_opts in SmartOS
# zonecfg -z <uuid>
# add attr
# set name=qemu-extra-opts
# set type=string
# set value="LXNtcCBjcHVzPTEsY29yZXM9NCx0aHJlYWRzPTI="
# end
# commit
# exit
Then reboot the machine. The value is the base64 encoded string that will be added to the qemu-kvm options. The above is "-smp cpus=1,cores=4,threads=2", which plays nice with Windows which for some stupid reason only supports 2 cpus.
@mattconnolly
mattconnolly / gist:7748711
Last active December 30, 2015 00:19
Typing garbage into ZMQ router socket with Telnet.
MattbookPro:~ matt$ telnet localhost 5555
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
asdfasdfasdf
asdfasd
fasdfasdfasdfasd
fasdfawdawdfawe