Skip to content

Instantly share code, notes, and snippets.

Aleksandar Kostadinov akostadinov

Block or report user

Report or block akostadinov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
akostadinov /
Last active Jan 16, 2020
Get stack trace in Bash shell script/program.
# LICENSE: MIT, wtfpl or whatever OSS license you like
function get_stack () {
local i message="${1:-""}"
local stack_size=${#FUNCNAME[@]}
# to avoid noise we start with 1 to skip the get_stack function
for (( i=1; i<$stack_size; i++ )); do
local func="${FUNCNAME[$i]}"
[ x$func = x ] && func=MAIN
local linen="${BASH_LINENO[$(( i - 1 ))]}"
akostadinov / timebench.groovy
Last active Nov 26, 2019
Benchmark Java Thread-Safe Time Formatter Implementations
View timebench.groovy
@Grab(group='org.gperfutils', module='gbench', version='[0.4,)'),
@Grab(group='org.apache.commons', module='commons-lang3', version='[3.7,)'),
@Grab(group='joda-time', module='joda-time', version='[2.9.9,)')
* Java 8 DateTimeFormatter
import java.util.Date;

A Low Level Format (LLF) means redefining physical disk layout. This is not doable by user on today's HDDs and SSDs. One usually want's to perform LLF to securely erase all data, reallocate bad sectors and/or remove malware.

[ATA Secure Erase][1]

Allows you to erase data on disk even on reallocated sectors. See:

akostadinov / xmr-stak.service
Last active Jun 24, 2019
Example xmr-stak systemd service unit file.
View xmr-stak.service
Description=xmr-stak miner
# interesting info about starting as regular user:
akostadinov / udp.rb
Created Feb 18, 2019
Ruby UDP echo server and client
View udp.rb
# echo server
Socket.udp_server_loop(4444) do |data, src|
src.reply data
# client
addr = Socket.sockaddr_in(4444, "localhost")
socket =, :DGRAM)
socket.send("hello\n", 0)
akostadinov /
Last active Jan 29, 2019
bash red hat prompt on Fedora 28
function _shell_char {
if [ "$_EXIT_CODE" -eq 0 ]; then
#printf "%s" "$"
printf "$RED$shellchar$RESET"
# printf "$RED$FancyX$RESET"
printf "$RED$collision$RESET"
akostadinov / pipeline_examples.groovy
Last active Jan 23, 2019
Jenkins Pipeline code Examples
View pipeline_examples.groovy
// clone in sub-directory
$class: 'GitSCM',
branches: [[name: 'master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[
$class: 'RelativeTargetDirectory',
relativeTargetDir: 'some/path'
submoduleCfg: [],
akostadinov / monty.rb
Created Jan 2, 2019
Monty Hall empirical proof
View monty.rb
require 'test/unit'
# Read about the problem and mathematical proof here:
class MontyHall
include Test::Unit::Assertions
akostadinov / recaptcha.php
Created Apr 1, 2018
Joomla 2.5 reCaptcha patch to support 2.0 API
View recaptcha.php
* @package Joomla.Plugin
* @subpackage Captcha
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note Sorry for the ugliness, just a quick patch to make this work with the 2.0 API, it also connects through TLS now. Just replace original plugins/captcha/recaptcha/recaptcha.php
akostadinov / _http_continue.txt
Last active Mar 28, 2018 — forked from trevorrowe/client.rb
Ruby Net::HTTP Expect-100 continue PUT bug
View _http_continue.txt
# Start the sample server. This server alternates between responding with 100-continue and
# resopnding with a 403 Forbidden. The client **should** be able to handle both responses.
$ ruby server.rb
# In another terminal window, run the client code twice. The first invocation will succeed.
# The second invocation will fail the client with an error.
$ ruby client.rb
$ ruby client.rb
You can’t perform that action at this time.