Skip to content

Instantly share code, notes, and snippets.

@wytten
wytten / two-main-jars-pom.xml
Created April 18, 2018 13:33 — forked from klausbrunner/two-main-jars-pom.xml
Creating two different executable JARs with dependencies from the same Maven project - same contents but different Main class in the manifest
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-assembly1</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
@wytten
wytten / gist:84a0a13547d697afb0059904cea02558
Last active May 11, 2016 15:23
Count log events per hour using awk, for a log file containing messages prefixed with date and time e.g., '2016-04-18 02:03:07'
$awk -F: '/logMessageOfInterest/ {counts[$1] = counts[$1] + 1; } END { for (val in counts) print val, counts[val]; }' LOG.TXT | sort
@wytten
wytten / static_server.js
Last active August 29, 2015 13:57 — forked from ryanflorence/static_server.js
Changed to serve files only out of a subdirectory named 'public_html'
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd() + "/public_html", uri);
@wytten
wytten / agent
Last active January 3, 2016 21:19 — forked from anonymous/april_temp_sensor
Updated original april_temp_sensor to remove use of deprecated methods, to remove the use of pin2 for activating the lamp, and to use CSV format for communication with xively.com. Also added agent code taken from https://xively.com/dev/tutorials/electric_imp to which I have made trivial modifications.
const FEED_ID = "YOUR_FEED_ID";
const API_KEY = "YOUR_API_KEY";
// Accept CSV from device, then format request to and accept response from xively.com
device.on("data", function(feedCSV) {
server.log(feedCSV);
local xively_url = "https://api.xively.com/v2/feeds/" + FEED_ID + ".csv";
local request = http.put(xively_url, {"X-ApiKey":API_KEY, "Content-Type":"text/csv", "User-Agent":"Xively-Imp-Lib/1.0"}, feedCSV);
local response = request.sendsync();
if(response.statuscode != 200) {
@wytten
wytten / spaceship.gsp
Last active December 16, 2015 07:09 — forked from aalmiray/gist:5395913
A GSP (Groovy Server Pages) variation of the technique
<% import org.codehaus.groovy.control.CompilerConfiguration %>
<% import org.wyttenbach.dale.groovy.spaceship.* %>
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
%>
<link rel="stylesheet" href="css/sample.css" type="text/css">
Here is a bunch of text