Skip to content

Instantly share code, notes, and snippets.

View misablaha's full-sized avatar

Michal Blaha misablaha

View GitHub Profile
const map = [
[4690, 0],
[4648, 20.0],
[4480, 30.0],
[4340, 45.0],
[4172, 60.0],
[3976, 80.0],
[3752, 100.0],
[3276, 150.0],
[2772, 200.0],
@misablaha
misablaha / rabbitmq.sh
Created April 25, 2019 12:44
Install RabbitMQ on Amazon Linux 2
sudo yum update -y
sudo yum install htop -y
# Install Erlang
sudo yum install https://github.com/rabbitmq/erlang-rpm/releases/download/v21.3.4/erlang-21.3.4-1.el7.x86_64.rpm -y
# Install RabbitMQ
sudo yum install https://dl.bintray.com/rabbitmq/all/rabbitmq-server/3.7.14/rabbitmq-server-3.7.14-1.el7.noarch.rpm -y
# Allow remote connections
@misablaha
misablaha / check-window.js
Created June 18, 2018 11:49
Babel plugin that checks access to global window variable
const { resolve: resolvePath } = require('path');
module.exports = (babel) => ({
visitor: {
Identifier(path, state) {
if (path.node.name === 'window') {
if (!path.scope.hasBinding('window')) {
const fileName = resolvePath(state.file.opts.filenameRelative);
const { start } = path.node.loc;
console.warn(`Global window is touched at ${fileName}:${start.line}:${start.column}`);
@misablaha
misablaha / semver-http.js
Last active June 9, 2018 11:10
firmware semver proof of concept
const path = require('path');
const fs = require('fs');
const express = require('express');
const semver = require('semver');
const app = express();
/**
* Get list of available files
*/
- ARCHIVE cluster (m1.xlarge)
- 4x HDD
- 8 ECU
- 15GiB mem
- 10 shards per node
- concurrency 1
┌────────────────────────────┬───────┬─────┬───────┬────────┬─────────┬─────────┐
│ index hit │ calls │ min │ max │ median │ mean │ 95 perc │
├────────────────────────────┼───────┼─────┼───────┼────────┼─────────┼─────────┤
@misablaha
misablaha / and_bool.txt
Last active August 29, 2015 14:21
Elasticsearch prformance test - random queries, random profile_ids and random sorting
filter AND vs BOOL
shards: 1 * 2 | docs: 59,925,838 | size: 23.51GB
=== and filter ===
filter cache: 4.8 GiB
┌────────────────────────────────┬───────┬─────┬─────┬────────┬───────┬─────────┐
│ type │ calls │ min │ max │ median │ mean │ 95 perc │
├────────────────────────────────┼───────┼─────┼─────┼────────┼───────┼─────────┤
│ total │ 1500 │ 1 │ 113 │ 4 │ 8.51 │ 26 │
├────────────────────────────────┼───────┼─────┼─────┼────────┼───────┼─────────┤
require 'mina/git'
require 'json'
set :domain, '0.0.0.0'
set :user, 'nodejs'
set :deploy_to, '/home/nodejs/api'
set :repository, 'git@.../api.git'
set :branch, 'master'
set :shared_paths, [ 'tmp' ]
set :term_mode, :pretty
{"profile_week": {
"type": "document",
"ids": ["446640741", "791886", "18338026", "14586934", "418565259", "272996263", "89724652", "593801316", "71065764", "56225142"],
"rows": 37027,
"many_fields": {
"unique_names": 24,
"sample_names": ["1330300800", "1335139200", "1328486400", "1332115200", "1329696000", "1336953600", "1339372800", "1331510400", "1336348800", "1349654400", "1338163200", "1329091200", "1333324800", "1339977600", "1334534400", "1330905600", "1337558400", "1332720000", "1333929600", "1335744000", "1338768000", "1327276800", "1326672000", "1327881600"],
"type": "object",
"fields": {
"date": {
@misablaha
misablaha / fact__profile.sql
Created May 27, 2014 06:27
Fulltext index on fact__profile
-- Column: vectors type of tsvector
ALTER TABLE profiles.fact__profile ADD COLUMN vectors tsvector;
-- Fill column: vectors (fulltext index)
UPDATE profiles.fact__profile
SET tsvector = to_tsvector('english', identifier || ' ' || title);
require('cson-config').load()
brokerClient = require 'broker-client'
config = process.config
app = brokerClient config.broker
# middleware
app.use (req, res, next)->
console.log "#{req.method} #{req.path} from #{req.headers['x-forwarded-for']}"