Skip to content

Instantly share code, notes, and snippets.

@jpg0
jpg0 / log.js
Created November 7, 2019 09:38
Graal/ES6 Logging lib for Openhab
const LOGGER_PREFIX = "org.eclipse.smarthome.model.script.jsr223.javascript";
class Logger{
constructor(_name, _listener) {
this._name = _name || this._getCallerDetails("", 3).fileName.replace(/\.[^/.]+$/, "")
this._listener = _listener;
this._logger = Java.type("org.slf4j.LoggerFactory").getLogger(LOGGER_PREFIX + "." + this.name.toString().toLowerCase());
}
_getCallerDetails (msg, ignoreStackDepth) {
@jpg0
jpg0 / ubuntu-configure-sendmail-with-gmail
Last active August 9, 2016 10:12 — forked from sshtmc/ubuntu-configure-sendmail-with-gmail
Ubuntu sendmail using smtp.gmail.com
#!/bin/bash
HOST=$(hostname)
function install_postfix() {
echo | sudo debconf-set-selections <<__EOF
postfix postfix/root_address string
postfix postfix/rfc1035_violation boolean false
postfix postfix/mydomain_warning boolean
postfix postfix/mynetworks string 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
@jpg0
jpg0 / gist:6360069
Created August 27, 2013 22:44
Colours in Erlang
split_rgb(Count) ->
HueDelta = 1.0 / Count,
Hues = [HueDelta * Position || Position <- lists:seq(1, Count)],
lists:map(fun(Hue) -> convert_hsv_to_rgb(Hue, 0.8, 0.5) end, Hues).
convert_hsv_to_rgb({H, S, V}) ->
I = trunc(H * 6),
F = H * 6 - I,
P = V * (1 - S),