troutwine

1

votes
2

answer
471

views

How can I DRY this puppet class?

I've got this code, does a slightly different action depending on whether or not the node is a Debian machine: class nginx::package { case $operatingsystem { 'debian': { apt::preference { 'nginx': package => 'nginx nginx-common', priority => '600', release => 'a=squeeze-backports', } package { 'ngi...
troutwine
1

votes
1

answer
598

views

Using `net_adm` modules functions for localhost development nodes

I'm poking around with the net_adm module and can't seem to get any joy working with localhost nodes. My machine is named: > hostname walden and I start up a few local short-named nodes: > erl -sname one -setcookie monster Erlang R16B (erts-5.10.1) [source] [64-bit] [smp:8:8] [async-threads:10...
troutwine
1

votes
1

answer
188

views

What does it mean that `gen_server` dodges auto-connections on sends but not suspends?

The gen_server implementation has this fun little function: do_send(Dest, Msg) -> case catch erlang:send(Dest, Msg, [noconnect]) of noconnect -> spawn(erlang, send, [Dest,Msg]); Other -> Other end. The entry for erlang:send/3 says of the noconnect option If the destination node would have to be auto...
troutwine
2

votes
3

answer
1.4k

views

How to limit the execution time of a function in C/POSIX?

Similar to this question, I'd like to limit the execution time of a function--preferably with microsecond accuracy--in C. I imagine that C++ exceptions could be used to achieve a result similar to this Python solution. Though it's not ideal, such an approach is wholly unavailable in plain C. I wonde...
troutwine
20

votes
2

answer
779

views

Is there any Haskell-land equivalent to the Ruby-land's Bundler et. al and, if not, how would a project so structured be contrived?

Note to readers: Bear with me. I promise there's a question. I have a problem to solve and think to myself 'Oh, I'll do it in Ruby.' $ bundle gem problemsolver create problemsolver/Gemfile create problemsolver/Rakefile create problemsolver/.gitignore create problemsolver/problemsolver.gemspec c...
troutwine
5

votes
2

answer
1.1k

views

Why does gem persist in installing to ~/.rvm after I've moved to rbenv?

I've decided to move away from rvm to rbenv on my personal machine. Followed the rvm removal instructions, installed rbenv and everything looks peachy. After restarting my shell session: $ rbenv global 1.9.3-p0 $ ls .rvm ls: cannot access .rvm: No such file or directory $ rbenv exec gem list *** LOC...
troutwine
5

votes
4

answer
295

views

Total Collections, rejecting collections of types that do not include all possibilities

Let's say we have the following types: sealed trait T case object Goat extends T case object Monk extends T case object Tiger extends T Now, how do you construct a collection of T such that at least one of each sub-T appears in the collection, this constraint being enforced at compile time? A collec...
troutwine
21

votes
6

answer
1.1k

views

What is the least horrible way to center an element with CSS?

I have html that looks like this: Some title thing, who knows One Two Three If I give header an auto margin and a width, it's horizontally centered. What's the least horrible way to ensure that it's vertically centered, as well? I am aware of the following articles which provide some discussion of t...
troutwine
11

votes
2

answer
22.9k

views

maven-assembly-plugin MojoExecutionException with dependencySet as outputDirectory

In my Khatami project I'm using maven to both manage compilation and package up the result into a runnable artifact: executable shell-script at the top-level, bin/ containing the executable jar and its dependent jars. Please see what I mean here. For reference, here's the salient part of Khatami's p...
troutwine
1

votes
1

answer
69

views

Correctly setting lifetimes and mutability expectations in Rust

I'm rather new to Rust and have put together a little experiment that blows my understanding of annotations entirely out of the water. This is compiled with rust-0.13.0-nightly and there's a playpen version of the code here. The meat of the program is the function 'recognize', which is co-responsib...
troutwine
4

votes
1

answer
2.3k

views

Rail3 rake test task not running tests

I have a very similar problem to Mr. Limpens, with one major different: I do include the test_unit railtie into my application.rb. From my application.rb: require File.expand_path('../boot', __FILE__) # Pick the frameworks you want:...
troutwine
2

votes
1

answer
427

views

Subsume external library into source tree with Autotools

I am developing a new project, using Autotools for my build infrastructure. I would like to subsume external dependencies into my source tree. These dependencies are using Autotools, as well. How can I configure my project's build scripts to build and link against subsumed dependencies? Though Duret...
troutwine
12

votes
3

answer
6.5k

views

How do I create a native Debian package for static files?

I have a need to Debianize some static resources for a software project but am confused by the available information and could use some guidance in doing so. Here are the materials I've been reading: Rolling your own Debian packages Debian New Maintainer's Guide Debian Library Packaging Guide Debian...
troutwine
5

votes
1

answer
1.4k

views

How can I use curl to test a Github post-receive hook server?

Github supports post-receive hooks for notification of code changes, documented here. Now, to test a hook server I need to post a bit of json and I'd like to use curl to do so. I've done this before but so infrequently that I tend to forget my solution. As I recall, it's been tedious each time. The...
troutwine
3

votes
1

answer
523

views

Why does net_kernel:monitor_nodes/2 not deliver nodeup/nodedown messages for sname nodes?

I start up a master node with a short name and get it running a process to monitor for node up and down messages. > erl -sname master -cookie monster Erlang R15B03 (erts-5.9.3) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false] [dtrace] Eshell V5.9.3 (abort with ^G) ([email protected]
troutwine
2

votes
2

answer
1k

views

What permissions does the health_check_user for pgpool-II need?

I'm confused about a point of pg_pool-II's documentation. The health_check_user is used to determine the health of DB cluster servers, but what abilities does the health_check_user need? As there are no configuration options to get a password for this user, I'm assuming that pg-pool's health_check_u...
troutwine
2

votes
2

answer
2.5k

views

Silencing Flyway — a log4j problem

I've written a wrapper around Flyway I call Nomad. I am well pleased with Flyway, save the incessant logging it performs outside of Maven. I created an issue here. Each user of Nomad must make their own configuration of log4j to silence Flyway. This is problematic if not done, for instance, during S...
troutwine
12

votes
2

answer
3.6k

views

How to assert that a class will respond_to a class method with RSpec?

Let's say I have a class definition like so: class Foo def init(val) @val = val end def self.bar :bar end def val @val end end with a spec like: describe Foo it { should respond_to(:val) } it { should respond_to(:bar) } end The second it assertion fails. It isn't clear to me from RSpec's documentati...
troutwine
4

votes
1

answer
355

views

Emacs: switch to buffer with a prefix

I have two files, both named server.pp. When I switch between buffers I see server.pp and server.pp. It is the case that one is module1/server.pp and the other module2/server.pp. How might I switch buffers in such a way as to include some path prefix information?
troutwine
7

votes
2

answer
2.7k

views

How to use Rust's Peekable?

I'm interested in peeking ahead in a character stream. To my understanding, Peekable would be the way to go. I can't quite figure out how to use it. First attempt: fn trawl(pk: &mut I) where I: std::iter::Peekable { loop { let cur = pk.next(); let nxt = pk.peek(); match (cur, nxt) { (Some(i), Some(...
troutwine
2

votes
1

answer
1.4k

views

Simple use of EM::Synchrony#sync causes 'root fiber' FiberError — my fault?

This program require 'em-synchrony' ## v1.0.0 require 'em-hiredis' ## v0.1.0...
troutwine
1

votes
3

answer
1.5k

views

How do I use mochijson to encode an array of objects?

I have two objects that I'd like to bundle up and ship in an array, encoded as JSON with mochijson. They are: > Book0 = {struct, [{'title', 'a book'}, {'id', '1'}]}. > Book1 = {struct, [{'title', 'another book'}, {'id', '2'}]}. However, > mochijson:encode({struct, [{'books', [Book0, Book1]}]}...
troutwine
4

votes
3

answer
748

views

SBT-like features in the Haskell build ecosystem

I've been using Scala with SBT quite a bit lately. The REPL loop of has a handy feature: ~ COMMAND, meaning perform COMMAND for every source file change in the project. For instance: ~ test and ~ compile are terrifically useful for rapid development. I wonder, does anyone know of something similar...
troutwine
3

votes
3

answer
1.1k

views

Suggestions for mocking an XMPP server [closed]

I have need to mock an XMPP server for testing purposes. My current intention is to run a local XMPP server and tie in my test code there, but I wonder if anyone is aware of an XMPP mocking library which already exists?
troutwine
3

votes
2

answer
571

views

How do I run Net::SSH and AMQP in the same EventMachine reactor?

Some background: Gerrit exposes an event stream through SSH. It's a cute trick, but I need to convert those events into AMQP messages. I've tried to do this with ruby-amqp and Net::SSH but, well, it doesn't seem as if the AMQP sub-component is even being run at all. I'm fairly new to EventMachine. C...
troutwine
4

votes
1

answer
2.7k

views

Create a Debian package from a Ruby gem

I'm attempting to create a Debian package for a simple utility I wrote with fpm and bundler but am having difficulties. Here's how I generate my .deb (I assume you've checked out sns and are in it's root): $ bundle install $ rake install $ fpm -s gem -t deb --prefix /var/lib/gems/1.8/ pkg/sns-0.1.1....
troutwine
13

votes
3

answer
15.4k

views

Jenkins and GitHub webhook: HTTP 403

I have a GitHub repository which I would like to have notify Jenkins of new commits via a post-receive hook. I've installed the GitHub plugin into Jenkins and have allowed for Jenkins to manage it's own hook URLs. The project has the correct git repository URL and is instructed to 'Build when a chan...
troutwine
3

votes
1

answer
1.8k

views

Display Rails3 Flash messages between format.html and format.js?

I would like to share FlashHash notices more cleanly between plain-old HTTP users and UJS folks that I've been able to contrive. Allow me to show you what I have first: First, part of the respond_to section of the relevant controller's #update: respond_to do |format| if @cont.save flash[:notice] = '...
troutwine
7

votes
1

answer
802

views

How can I effectively use the start code features of Alex?

I'm starting to learn Alex and believe I've gotten to the point where stateful context would be helpful, but I'm not entirely sure how to go about it. I'm attempting to lex a limited subset of erlang binaries. With the following lexer: { module Main (main, Token(..), AlexPosn(..), alexScanTokens, to...
troutwine
7

votes
2

answer
6.1k

views

Unique constraint over multiple tables

Let's say we have these tables: CREATE TABLE A ( id SERIAL NOT NULL PRIMARY KEY ); CREATE TABLE B ( id SERIAL NOT NULL PRIMARY KEY ); CREATE TABLE Parent ( id SERIAL NOT NULL PRIMARY KEY, aId INTEGER NOT NULL REFERENCES A (id), bId INTEGER NOT NULL REFERENCES B (id), UNIQUE(aId, bId) ); CREATE TABLE...
troutwine
4

votes
1

answer
466

views

Capture the entire contiguous matched input with nom

I'm looking to apply a series of nom parsers and return the complete &str that matches. I want to match strings of the form a+bc+. Using the existing chain! macro I can get pretty close: named!(aaabccc , map_res!( chain!( a: take_while!(is_a) ~ tag!('b') ~ take_while!(is_c) , || {a} ), from_utf8 ));...
troutwine
2

votes
1

answer
705

views

Xmonad: How do I reset the number of windows in the master pane?

It sometimes happens that when I mod-L or mod-H in Xmonad my windows don't resize. I believe this is a result of my having accidentally changed the number of windows in my master pane. Sometimes I'm lucky to hit just the right amount of mod-, or mod-. to get back to where I can resize, but not often...
troutwine
6

votes
1

answer
259

views

How to specify the type for a heterogenous collection in a GADT formulated AST?

I'd like to make a typed AST for a dynamic language. At present, I'm stuck on handling collections. Here's a representative code sample: {-# LANGUAGE GADTs #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE ExistentialQuantification #-} data Box = forall s. B s data BinOp =...
troutwine
8

votes
2

answer
2.4k

views

How to disable automatic title inclusion in org-mode HTML export?

I have an org-mode project with many small org files that I'd like to export to HTML. I have not set #+TITLE in many files as they do not have proper titles. I find on export that the partial first sentence is exported as the document's title. For instance, an org document like so: This is a short...
troutwine
2

votes
4

answer
795

views

Recognize floating point from input with nom

I'm trying to use nom to parse a text based protocol. This protocol can have floating point values in it of the form: [-]digit+[.digit+] Examples of which are: -10.0 10.0 10 The nom parser I've built to recognize this is... not pretty. It also doesn't quite typecheck. What I've got so far: named!(fl...
troutwine
3

votes
2

answer
419

views

Why does an ets table survive ct:init_per_testcase but not init_per_suite?

I have a common test suite that attempts to create an ets table for use in all suites and all test cases. It looks like so: -module(an_example_SUITE). -include_lib('common_test/include/ct.hrl'). -compile(export_all). all() -> [ets_tests]. init_per_suite(Config) -> TabId = ets:new(conns, [set]), ets:...
troutwine
2

votes
1

answer
308

views

How to create a Quickcheck Arbitrary of a struct containing a reference?

The Rust quickcheck documentation notes that for any type implementing Arbitrary They must also be sendable and static since every test is run in its own thread using thread::Builder::spawn, which requires the Send + 'static bounds. If I need to generate data for a struct that contains a reference h...
troutwine
2

votes
1

answer
1.1k

views

Why does this erlang ssh daemon repond with 'no hostkey alg'?

I'm a little confused with the OTP ssh daemon implementation's behaviour and I wonder if someone might clear things up for me. Preliminaries; I have the following program: -module(sshd). -export([start/0, stop/1]). -spec start() -> {ok, ssh:ssh_daemon_ref()} | {error, atom()}. start() -> _ = applica...
troutwine
3

votes
2

answer
1.1k

views

Unintentional concatenation in Bison/Yacc grammar

I am experimenting with lex and yacc and have run into a strange issue, but I think it would be best to show you my code before detailing the issue. This is my lexer: %{ #include #include #include 'y.tab.h' void yyerror(char *); %} %% [a-zA-Z]+ { yylval.strV = yytext; return ID; } [0-9]+ { yy...
troutwine
5

votes
2

answer
760

views

Is it possible to run a git commit-msg hook over past commits?

I have a commit-msg hook that I run for all of my local commits and, for a certain project, I require to have been run. Problem is, when I pull in from other forks some of my compatriots have not run this commit-msg hook. To date I've been doing $ git rebase --interactive $commit_parent as outlined...
troutwine

View additional