Skip to content

Instantly share code, notes, and snippets.

@robshep
robshep / overlappingQueueDispatch.js
Created September 28, 2012 11:45
Mutex for overlapping online queue dispatching in JS (node)
var $ = require("jquery");
var things = ["a", "b", "c", "d", "e", "f"];
var mutex = 0;
var onSuccess = function( data){
console.log(" Success: " + data + " [" + mutex + "]");
var sentThing = things.shift();
console.log(" Dequeue item: " + sentThing + " [" + mutex + "]")
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import journal.io.api.Journal;
import java.util.*;
public class Partition {
public static void partition(int n, int l) {
partition(n, n, new ArrayList<Integer>(), l);
}
public static void partition(int n, int max, ArrayList<Integer> prefix, int l) {
if (n == 0 && prefix.size() == l) {
System.out.print(prefix);

Java to Objective-C Cribsheet

@robshep
robshep / piboot
Created December 14, 2013 22:09
LSB start/stop script to email when a Pi starts/stops (change variables!)
#!/bin/sh
### BEGIN INIT INFO
# Provides: piboot
# Required-Start: $ntp $network $remote_fs $syslog
# Required-Stop: $ntp $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Emails out when the pi boots/shutsdown
### END INIT INFO
@robshep
robshep / whatsup
Created January 11, 2014 14:46
Expect script to get OpenVPN status
#!/usr/bin/expect
set timeout 20
# I have the management server at tcp:localhost:1194
spawn telnet localhost 1194
expect ">INFO:OpenVPN Management Interface Version 1*"
send "status\n"
expect "END"

MODBUS Issue

a selection of 3 sequential periodic "reads".

(each comprising 6 modbus command/response pairs)

Showing....

/**
* simple groovy server using spring boot
*
* spring run script.groovy
*
* uses:
*
* https://spring.io/blog/2013/08/06/spring-boot-simplifying-spring-for-everyone
* http://spring.io/guides/gs/uploading-files/
*
@robshep
robshep / pom.xml-snippet
Created December 30, 2014 22:24
Force sping profile "test" during maven testing
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<spring.profiles.active>test</spring.profiles.active>
</systemPropertyVariables>
</configuration>
{
"plugins" : {
"metalsmith-static": {
"src": "public",
"dest": "."
}
}
}