Skip to content

Instantly share code, notes, and snippets.

View tomquas's full-sized avatar

tom quas tomquas

  • patugo GmbH
  • munich, germany
View GitHub Profile
@tomquas
tomquas / vmdump.sh
Last active December 24, 2015 13:49 — forked from tehmaze/vmdump.sh
#!/bin/bash
if echo ${1} | grep -q '^vmnet[0-9]$'; then
ERRCOUNT='0'
PIDSNIFF='0'
PIDTDUMP='0'
CAPINTF="${1}"
CAPFILE="$(mktemp -t capture)"
#!/bin/bash
# Install rbenv
# https://github.com/sstephenson/rbenv
cd ~
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> .bash_profile
echo 'eval "$(rbenv init -)"' >> .bash_profile
first = {"a" => 4, "b" => 1, "c" => 3, "g" => 201, "h" => 501}
second = {"d" => 19, "e" => 18, "c" => 17, "g" => 201, "h" => 501}
keys_intersection = first.keys & second.keys
merged = first.dup.update(second)
intersection = {}
keys_intersection.each do |k|
intersection[k]=merged[k] unless first[k] != second[k]
end
@tomquas
tomquas / xmpp server comparison
Last active September 10, 2020 16:41
performance testing prosody, tigase, ejabberd
motivation
* test xmpp bot behavior with different servers, measure throughput and reliability.
* figure out numbers for prosody, nothing seems to be published at the time of writing
* the goal was _not_ to push the servers to their limits, so the test environment was not highly optimized.
test setup
* macbook pro hosting ubuntu raring on vmware fusion.
* communication flow: xmpp client (osx) > xmpp server (ubuntu) > xmpp bot (osx).
* client opens 20 connections to server and pumps 150 iq stanzas (similar disco#items) to bot. this is being repeated 40x.
* servers:
@tomquas
tomquas / 0_reuse_code.js
Created January 15, 2014 15:54
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@tomquas
tomquas / influxdb-udp.rb
Created June 30, 2014 14:17
fill influxdb w/ semi-random data
require 'socket'
require 'json'
total = ARGV.first.to_i || 1_000
packets_per_run = 1_000
def send_bulk(socket, packets)
packets.times do
socket.send [{name:"udp", columns:["v"], points:[[rand]]}].to_json, 0
end
local st = require "util.stanza";
local jid_bare = require "util.jid".bare;
local xmlns_push = "urn:xmpp:push:0";
local full_sessions, bare_sessions = full_sessions, bare_sessions;
local recipients = {};
local function toggle_push(event)
local origin, stanza = event.origin, event.stanza;
local user = stanza.attr.to or (origin.username..'@'..origin.host);
@tomquas
tomquas / rmtree.rb
Last active August 29, 2015 14:12 — forked from beeftornado/rmtree.rb
# Install to /usr/local/Library/Homebrew/cmd/rmtree.rb
require 'keg'
require 'formula'
require 'shellwords'
module Homebrew
def rmtree
raise KegUnspecifiedError if ARGV.named.empty?
#!/bin/sh
gem dependency | grep ^Gem | cut -d' ' -f2 | sed -e 's/\(.*\)-[0-9]\.[0-9.]*/\1/' | uniq
@tomquas
tomquas / version_task.rb
Last active August 29, 2015 14:21
rake task to generate version.rb file from git metadata
require 'fileutils'
require 'bundler/gem_tasks'
require 'git'
def gen_version_file(version, build, filename)
data = []
data << "# --- GENERATED BY RAKE. DON'T MODIFY"
data << 'module Patugo::Search'
data << " VERSION = '#{version}'"
data << " BUILD = '#{build}'"