Skip to content

Instantly share code, notes, and snippets.

Avatar

Aleksandar Kostadinov akostadinov

View GitHub Profile
@akostadinov
akostadinov / jenkins-job-param.groovy
Last active Oct 16, 2020
Jenkins Job deafault value of parameter of a job
View jenkins-job-param.groovy
job = Jenkins.getInstance().getItem("Flexy-install")
println job.getProperty(ParametersDefinitionProperty.class)?.getParameterDefinition("REPOSITORIES")?.getDefaultParameterValue()
/*
License: https://en.wikipedia.org/wiki/WTFPL
Some readers:
https://support.cloudbees.com/hc/en-us/articles/226941767-Groovy-to-list-all-jobs
https://medium.com/@mukeshsingal/update-default-values-of-jenkins-job-parameters-416de5ff9f96
https://javadoc.jenkins.io/hudson/model/Job.html
@akostadinov
akostadinov / touchpad_toggle.sh
Created Apr 19, 2020
Turn on and off a libinput device.
View touchpad_toggle.sh
# the above works with synaps driver
DEV="SynPS/2 Synaptics TouchPad"
# DEV="Synaptics TM3053-006"
toggle_touchpad () {
local enabled=`xinput list-props "$DEV" | awk '/Device Enabled/{ print $4 }'`
case "$enabled" in
0) xinput enable "$DEV"
;;
1) xinput disable "$DEV"
;;
@akostadinov
akostadinov / jenkins_creds_script.groovy
Last active May 7, 2020
jenkins credentials obtain on script console
View jenkins_creds_script.groovy
com.cloudbees.plugins.credentials.SystemCredentialsProvider.getInstance().getCredentials().forEach{
it.properties.each { prop, val ->
if (prop == "secretBytes") {
println(prop + "=>\n" + new String(com.cloudbees.plugins.credentials.SecretBytes.fromString("${val}").getPlainData()) + "\n")
} else {
println(prop + ' = "' + val + '"')
}
}
println("-----------------------")
}
@akostadinov
akostadinov / fahclient.service
Last active Mar 18, 2020
fahclient.service
View fahclient.service
[Unit]
Description=FAHClient cruncher
After=syslog.target network.target
[Service]
Type=simple
User=fahclient
WorkingDirectory=/var/lib/fahclient
EnvironmentFile=-/etc/sysconfig/fahclient
# log will go fahclient home dir
@akostadinov
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
end
# client
addr = Socket.sockaddr_in(4444, "localhost")
socket = Socket.new(:INET, :DGRAM)
begin
socket.send("hello\n", 0)
@akostadinov
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:
# http://www.greenteapress.com/thinkbayes/html/thinkbayes002.html#sec15
class MontyHall
include Test::Unit::Assertions
NUM_DOORS = 3
@akostadinov
akostadinov / prompt_include.sh
Last active Jan 29, 2019
bash red hat prompt on Fedora 28
View prompt_include.sh
function _shell_char {
if [ "$_EXIT_CODE" -eq 0 ]; then
#printf "%s" "$"
printf "$RED$shellchar$RESET"
else
# printf "$RED$FancyX$RESET"
printf "$RED$collision$RESET"
fi
}
@akostadinov
akostadinov / recaptcha.php
Created Apr 1, 2018
Joomla 2.5 reCaptcha patch to support 2.0 API
View recaptcha.php
<?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
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
View Low_Level_Format_Disk.md

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:

You can’t perform that action at this time.