Skip to content

Instantly share code, notes, and snippets.

View andsel's full-sized avatar

Andrea Selva andsel

  • Trento area
View GitHub Profile
class abstract Geometry {
abstract Geometry envelope();
}
clas Rect extends Geometry {
public Rect(int height, int width) {...}
}
class Circle extends Geometry {
public Geometry envelope() {
@andsel
andsel / copy_twbs_scaffold.sh
Created June 15, 2012 09:00
Simple script to copy twitter bootstrap scaffolding in a new project
#!/bin/sh
#Usage copy_twbs_scaffold scaffoleding_git_cloned destination_prj
echo "Coping twitterbootstrap scaffold files \n from: $1 \n to: $2"
mkdir -p $2/src/templates/scaffolding
cp $1/src/templates/scaffolding/* $2/src/templates/scaffolding;
cp $1/web-app/css/scaffolding.css $2/web-app/css/
echo "WARN overwriting of your existent conf iguration, please re-check it!!"
cp -Rf $1/grails-app/conf $2/grails-app/
@andsel
andsel / CustomSuiteAS.java
Created December 11, 2019 11:15
Test sequence
@RunWith(Suite.class)
@Suite.SuiteClasses({
org.logstash.AccessorsTest,
org.logstash.ackedqueue.CheckpointTest,
org.logstash.ackedqueue.HeadPageTest,
org.logstash.ackedqueue.io.FileCheckpointIOTest,
org.logstash.ackedqueue.io.FileMmapIOTest,
org.logstash.ackedqueue.io.IntVectorTest,
org.logstash.ackedqueue.io.LongVectorTest,
org.logstash.ackedqueue.io.MmapPageIOTest,
@andsel
andsel / QueuePerfTest.java
Created March 30, 2020 09:52
queue throughput perf check
import org.eclipse.jetty.toolchain.perf.PlatformTimer;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.IOException;
import java.util.concurrent.*;
@andsel
andsel / bombing_client.rb
Created October 5, 2020 14:44
client flood TCP request
#!/usr/bin/env ruby
require 'socket'
host = "localhost"
port = 5043
PAYLOAD = "System.Runtime.InteropServices.COMException (0x80004005): Error recived. at UiPath.UiNodeClass.Get(String bstrAttr) at UiPath.Core.UiElement.IsElementReady()\r"
def request_close(host, port)
client = TCPSocket.open(host, port)
@andsel
andsel / checkpoint_scanner.rb
Last active March 22, 2021 17:09
Dump contents of Logstash checkpoint files
#!/usr/bin/env ruby
class CheckpointDecoder
attr_reader :path
def initialize(path)
@path = path
end
@andsel
andsel / sender.rb
Last active June 2, 2021 10:28
Simple RabbitMQ sender
#run dockerized RabbitMQ
# docker run -v rabbitmq-data:/var/lib/rabbitmq --hostname my-rabbit --name rabbit_dev -p 15672:15672 -p 5672:5672 rabbitmq:3-management
# navigate to http://localhost:15672/#/queues
# login guest:guest
require 'march_hare'
conn = MarchHare.connect(:host => "localhost")
ch = conn.create_channel
exchange = ch.direct("sysmsg", :durable => true)
@andsel
andsel / gist:f1f92dbab4757519bfc720650cd5e012
Created June 17, 2021 11:04
dump of .\gradlew assemble on windows
> Task :installDefaultGems FAILED
#<Class:0x71bf592a>: Command failed with status (1): [./gradlew assemble...]
create_shell_runner at C:/Users/andrea/workspace/logstash/vendor/bundle/jruby/2.5.0/gems/rake-12.3.3/lib/rake/file_utils.rb:67
sh at C:/Users/andrea/workspace/logstash/vendor/bundle/jruby/2.5.0/gems/rake-12.3.3/lib/rake/file_utils.rb:57
<main> at C:/Users/andrea/workspace/logstash/rakelib/compile.rake:34
execute at C:/Users/andrea/workspace/logstash/vendor/bundle/jruby/2.5.0/gems/rake-12.3.3/lib/rake/task.rb:273
each at org/jruby/RubyArray.java:1820
execute at C:/Users/andrea/workspace/logstash/vendor/bundle/jruby/2.5.0/gems/rake-12.3.3/lib/rake/task.rb:273
invoke_with_call_chain at C:/Users/andrea/workspace/logstash/vendor/bundle/jruby/2.5.0/gems/rake-12.3.3/lib/rake/task.rb:214
mon_synchronize at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/monitor.rb:237
@andsel
andsel / pipeline.conf
Created July 19, 2021 09:37
Logstash ruby filter - remove leafs of a path selected by regexp
# input sample: {"name": "John", "outer": {"inner": {"leaf_1": "a leaf 1", "leaf_2": "a leaf 2", "leaf_3": "a leaf 3"}}}
input {
stdin {
codec => json
}
}
filter {
ruby {
@andsel
andsel / Docker.alpine
Created October 5, 2021 10:24
Dockerfile used to verify Logstash with JDK16 under Alpine Linux
FROM adoptopenjdk/openjdk16:x86_64-alpine-jdk-16.0.1_9
WORKDIR /root
RUN adduser --disabled-password --gecos "" --home /home/logstash logstash && \
mkdir -p /usr/local/share/ruby-build && \
mkdir -p /opt/logstash && \
mkdir -p /opt/logstash/data && \
mkdir -p /mnt/host && \
chown logstash:logstash /opt/logstash