Skip to content

Instantly share code, notes, and snippets.

View thomassuckow's full-sized avatar

Thomas Suckow thomassuckow

View GitHub Profile
@thomassuckow
thomassuckow / ExtractEmailBodyText.java
Created November 10, 2017 16:30
Nifi Extract Email Body Text Processor
package foo;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import java.nio.charset.StandardCharsets;
import org.apache.nifi.annotation.behavior.InputRequirement;
import org.apache.nifi.annotation.documentation.CapabilityDescription;
{
"parser": "babel-eslint",
"env": {
// I write for browser
"browser": true,
// in CommonJS
"node": true
},
"plugins": [
"react"
@thomassuckow
thomassuckow / eventEmitter.js
Created February 12, 2016 05:49
A basic event emitter
import _ from 'lodash';
const events = Symbol('Events');
export default class EventEmitter {
constructor() {
this[events] = {};
}
on(event, fn) {
const listeners = this[events][event] = this[events][event] || [];
@thomassuckow
thomassuckow / index.html
Last active February 9, 2016 17:52 — forked from njvack/LICENSE
Voronoi-based point picker
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js"></script>
</head>
<body>
<div id="chart">
</div>
<script type="text/javascript">
var w = 960,
@thomassuckow
thomassuckow / proxy.sh
Created November 18, 2014 23:24
Script to limit the number of running processes to one more than the number of cores. Symlink this script to /usr/local/bin/ named as the binary you want to throttle.
#!/bin/bash
CMD=$(basename $0) # command used to call this script
CMD=$(type -a -p $CMD | sed -n 2p) #find the next highest priority
RUNNING=$(grep procs_running /proc/stat|cut -d " " -f 2)
BLOCKED=$(grep procs_blocked /proc/stat|cut -d " " -f 2)
PROCESSLIMIT=$(grep cpu /proc/stat | wc -l)
#Wait for running processes to die down
# Copyright (C) 2002-2003 David Abrahams.
# Copyright (C) 2002-2003 Vladimir Prus.
# Copyright (C) 2003,2007 Rene Rivera.
# Use, modification and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# This is the initial file loaded by Boost Jam when run from any Boost library
# folder. It allows us to choose which Boost Build installation to use for
# building Boost libraries. Unless explicitly selected using a command-line
@thomassuckow
thomassuckow / karma.js
Last active June 18, 2017 13:26
Using karma to load requirejs tests with the .spec.js suffix. Note the base url needs the / otherwise karma-requirejs will whine about no timestamp (paths will differ) We mangle the files list to be relative, otherwise using relative paths in the form of "./bar" will fail. In my use case I have a shared config.js file that has more configuration…
var tests = Object.keys(window.__karma__.files).filter(function (file) {
return /\.spec\.js$/.test(file);
}).map(function(file){
return file.replace(/^\/base\/src\/js\/|\.js$/g,'');
});
require.config({
baseUrl: '/base/src/js',
paths: {
"lib":"../../target/js/lib"