Skip to content

Instantly share code, notes, and snippets.

View thbkrkr's full-sized avatar
🐳

Thibault Richard thbkrkr

🐳
View GitHub Profile
@thbkrkr
thbkrkr / i3-shortcuts.txt
Created August 20, 2016 08:17
i3 shortcuts
bindsym $mod+Return exec lxterminal
bindsym $mod+t exec lxterminal
bindsym $mod+g exec google-chrome
bindsym $mod+s exec stx
bindsym $mod+d exec dmenu_run
bindsym $mod+l exec i3lock -c 111111
bindsym $mod+k kill
bindsym $mod+m move scratchpad
bindsym $mod+o scratchpad show
bindsym $mod+Left focus left
@thbkrkr
thbkrkr / api.go
Last active July 16, 2016 22:30
Docker run command from an HTTP API (gin-gonic)
package api
import (
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
)
func Sdocker(c *gin.Context, image string, cmd ...string) {
version: '2'
services:
logspout:
image: gliderlabs/logspout
container_name: logspout
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- SYSLOG_STRUCTURED_DATA=- X-OVH-TOKEN="<set-your-token-here>"
ports:
@thbkrkr
thbkrkr / main.go
Created May 23, 2016 14:27
Service checks collector - #poc
package main
import (
"net/http"
"sync"
"github.com/gin-gonic/gin"
)
func main() {
@thbkrkr
thbkrkr / containers.sh
Last active May 3, 2016 09:20
Call Docker Remote API for all machines in docker-machine
#!/bin/bash -eu
#
# Call Docker Remote API for all machines in docker-machine.
#
get() {
local node=$1
local path=$2
declare ip=$(docker-machine ip $node)
@thbkrkr
thbkrkr / main.go
Created March 31, 2016 16:55
mailme
package main
import (
"flag"
"net/smtp"
"github.com/Sirupsen/logrus"
)
var (
@thbkrkr
thbkrkr / ovh-iot-paas-ts-api-example.js
Created December 7, 2015 14:19
OVH IoT PaaS TS API - Javascript example
var tokenId = '?';
var tokenKey = '?';
var metricName = '?';
var start = '?';
$.ajax({
url: 'https://opentsdb.iot.runabove.io/api/query',
type: 'POST',
data: JSON.stringify({
start: start,
@thbkrkr
thbkrkr / influx2otsdb.sh
Last active November 27, 2015 09:38
poc: InfluxDB line protocol to OpenTSDB JSON protocol
#!/bin/bash -eu
# [key] [fields] [timestamp]
# temperature,machine=unit143,type=assembly internal=22,external=130 1434055562005000035
split() { tr "$2" "\n" <<< $1; }
get() { cut -d '=' -f$2 <<< $1; }
point() {
local timestamp=$1
@thbkrkr
thbkrkr / get.js
Created September 18, 2015 20:45
function get(path, el, template)
function microAjax(B,A){this.bindFunction=function(E,D){return function(){return E.apply(D,[D])}};this.stateChange=function(D){if(this.request.readyState==4){this.callbackFunction(this.request.responseText)}};this.getRequest=function(){if(window.ActiveXObject){return new ActiveXObject("Microsoft.XMLHTTP")}else{if(window.XMLHttpRequest){return new XMLHttpRequest()}}return false};this.postBody=(arguments[2]||"");this.callbackFunction=A;this.url=B;this.request=this.getRequest();if(this.request){var C=this.request;C.onreadystatechange=this.bindFunction(this.stateChange,this);if(this.postBody!==""){C.open("POST",B,true);C.setRequestHeader("X-Requested-With","XMLHttpRequest");C.setRequestHeader("Content-type","application/x-www-form-urlencoded");C.setRequestHeader("Connection","close")}else{C.open("GET",B,true)}C.send(this.postBody)}};
var url = window.location.href.split("/");
function get(path, el, template) {
microAjax(url[0] + "//" + url[2] + path, function(data) {
var ractive = new Ractive({el: el, templ
@thbkrkr
thbkrkr / mail-ip.sh
Last active September 12, 2015 17:41
Script to send eth0 local IP (192.xxx) by email (with Mandrill) on startup (useful for Raspberry Pi)
#!/bin/bash
set -eu
MANDRILL_KEY="****************"
FROM=pi@pi.pi
TO=your@ema.il
mail() {
local ip="$1"