Skip to content

Instantly share code, notes, and snippets.

View threez's full-sized avatar

threez

  • IONOS SE
  • Karlsruhe, Germany
View GitHub Profile
all: pulse lcd
pulse: pulse.c
clang -lgpio -o $@ $<
lcd: lcd.c lcd.h lcd_const.h
clang -o $@ $<
@threez
threez / rspec.xml
Created July 31, 2017 08:36
rspec.xml with errors
<?xml version="1.0" encoding="UTF-8"?>
<!-- source https://stackoverflow.com/questions/4922867/junit-xml-format-specification-that-hudson-supports -->
<testsuite>
<!-- if your classname does not include a dot, the package defaults to "(root)" -->
<testcase name="my testcase" classname="my package.my classname" time="29">
<!-- If the test didn't pass, specify ONE of the following 3 cases -->
<!-- option 1 --> <skipped />
@threez
threez / README.md
Last active April 18, 2016 09:24
gometalinter JSON top checkstyle converter for jenkins

Usage

gometalinter --deadline=5s ./... --json | ./goml2checkstyle.rb > checkstyle.xml

If the output doesn't show up, the prefix path might not be detected correctly. Pass the path in manually then:

gometalinter --deadline=5s ./... --json | ./goml2checkstyle.rb /absolute/path/to/the/files > checkstyle.xml

@threez
threez / perl.rb
Created May 5, 2015 13:57
Simply execute perl code from ruby
require 'open3'
module Perl
def self.exec(code)
pstdin, pstdout, pstderr = Open3.popen3('perl')
pstdin.write code
pstdin.close
data = pstdout.read
err = pstderr.read
if err.size > 0
@threez
threez / mini-sqlite3.rb
Last active August 29, 2015 14:16
minimal sqlite3 driver
#!/usb/bin/env ruby
require 'fiddle'
require 'fiddle/import'
require 'pp'
module Sqlite3
SQLITE_OK = 0
module Driver
extend Fiddle::Importer
@threez
threez / dolight.js
Created April 19, 2014 18:11
Use ban to turn off/on the light if the door was opened
#!/usr/bin/env node
var WebSocketClient = require('websocket').client,
client = new WebSocketClient(),
url = 'ws://localhost:8080/',
light = '11011C';
function handleMessage(connection, data) {
var now = new Date();
// door was opened turn on the light
if (data['door-opened']) {
@threez
threez / update_keystore_ldap.sh
Created March 3, 2014 10:20
Extract and update a ldap certificate in a java keystore (jenkins)
#!/bin/bash
LDAP_SERVER=example.com:636
ALIAS=LDAP_SERVER
KEYSTORE=/usr/lib/jvm/java-1.6.0-openjdk-amd64/jre/lib/security/cacerts
PASSWD=changeit
# grep the certificate
echo -n | openssl s_client -connect $LDAP_SERVER | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ldaps.crt
@threez
threez / node-http-parser.js
Created January 23, 2014 07:42
In this example I played with the internal node http parser. This might be useful to folks that have to parse HTTP manually. For more info look at: https://github.com/joyent/node/blob/master/lib/_http_client.js
var HTTPParser = process.binding('http_parser').HTTPParser;
var parser = require("http").parsers.alloc();
parser.reinitialize(HTTPParser.RESPONSE);
parser.onBody = function(body) {
console.log(body.toString());
}
parser.onIncoming = function(response) {
console.log(response.headers);
console.log(response.statusCode);
@threez
threez / pipe-rpc.rb
Created September 6, 2013 14:11
Simple RPC over a unix PIPE
class Message < Struct.new(:type, :payload)
REQUEST = ?<.freeze
RESPONSE = ?>.freeze
HEADER = 'NA'.freeze
CODER = Marshal
def self.request(payload)
new(REQUEST, payload)
end
@threez
threez / mp3converter.rb
Created August 18, 2013 19:07
A simple script to convert m4a files into mp3 out of the itunes library. Best used in conjunction with the 'request itunes titles' automator task.
#!/usr/bin/env ruby
require 'open3'
require 'fileutils'
USER = 'XXX
CMD = '/Applications/CocoaDialog.app/Contents/MacOS/CocoaDialog'
MUSIC_LOCATION = "/Users/#{USER}/Music/iTunes/iTunes Music/"
TARGET_DIR = "/Users/#{USER}/Musik MP3"
# start cocoa dialog for progress bar