Skip to content

Instantly share code, notes, and snippets.

@motine
motine / README.md
Last active August 29, 2015 14:08
docker elasticsearch kibana try-out

Story

Daemon

To start the elastisearch container (no persistance): docker run -d -p 9200:9200 -p 9300:9300 --name els dockerfile/elasticsearch

See if the daemon is up: docker ps

Populate

@motine
motine / syntax-highlighted-for-markdown
Last active August 29, 2015 14:10
Syntax Highlight for Mou
<!-- add at the end of the document, more info see https://highlightjs.org/ -->
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/monokai_sublime.min.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/highlight.min.js"></script>
<script>
hljs.initHighlightingOnLoad();
</script>
hex_colors=["1f77b4", "ff7f0e", "2ca02c", "d62728", "9467bd", "8c564b", "e377c2", "7f7f7f", "bcbd22", "17becf", "1f77b4", "ff7f0e", "2ca02c"]
values = hex_colors.collect do |hex|
(0..2).collect do |cindex| # collect components (r,g,b)
chex = hex[(cindex*2)..(cindex*2+1)]
c = chex.to_i(16) # convert from hex
mix = c * 0.25 + 255 * 0.75 # mix original color with white (equivalent to 0.25 opacity)
mix.to_i.to_s(16) # convert to hex
end.join()
end
p values
@motine
motine / svg_preset.html
Last active August 29, 2015 14:27
this can easily be copied into a markdown document
<style type="text/css">
/* colors (e.g. for text)*/
.c1 { fill-opacity: 1.00; fill: #1f77b4; }
.c2 { fill-opacity: 1.00; fill: #ff7f0e; }
.c3 { fill-opacity: 1.00; fill: #2ca02c; }
.c4 { fill-opacity: 1.00; fill: #d62728; }
.c5 { fill-opacity: 1.00; fill: #9467bd; }
.c6 { fill-opacity: 1.00; fill: #8c564b; }
.c7 { fill-opacity: 1.00; fill: #e377c2; }
.c8 { fill-opacity: 1.00; fill: #7f7f7f; }
@motine
motine / mermaid_test.html
Created August 11, 2015 19:43
Testing the library which claims to be the markdown for graphs. Verdict: nice work, but styling nodes is tedious.
<style type="text/css">
svg {
border: 1px #999 solid;
margin: auto;
}
foreignobject>div {
font-family: Avenir Next, Avenir, sans-serif;
font-size: 11pt;
}
</style>
@motine
motine / project.c
Last active September 18, 2015 18:22
use STA to print a number.
#include "sketchbook.h"
void setup() {
}
void draw() {
int result = 77; // this would be your solution
// use the following code to output the result
char buffer[100];
sprintf(buffer, "%i", result);
@motine
motine / README.md
Last active October 12, 2021 03:35
Redis Pub/Sub with Python (notes for my collegue)

Redis Pub/Sub with Python

Overview:

  • Redis supports PUB/SUB
  • It supports pattern matching. Clients may subscribe to glob-style patterns in order to receive all the messages sent to channel names matching a given pattern.

Prerequisites

Assuming Fedora 23.

@motine
motine / simple_matplot_without_x.py
Last active March 23, 2016 09:57
Matplotlib example (no X needed)
# install: `dnf install python-matplotlib` under Fedora 23
# example inspired by: http://matplotlib.org/users/screenshots.html
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)
plt.plot(t, s)
BASE_PATH = File.expand_path("~/Repositories/beauty")
LINE_LENGTH_THRESHOLD = 150
above, total = 0, 0
Dir[File.join(BASE_PATH, "**/*.rb")].each do |path|
contents = File.readlines(path)
above += contents.count { |line| line.length > LINE_LENGTH_THRESHOLD }
total += contents.size
end
@motine
motine / Hello.vue
Last active March 28, 2020 11:32
Rollup multi page bundles
<template>
<div class="hello">Hello {{ name }}.</div>
</template>
<script>
export default {
data() { return { name: 'Manfred' } }
}
</script>