Skip to content

Instantly share code, notes, and snippets.

View LukeSavefrogs's full-sized avatar
💭
Thinking about what to script next

Luca Salvarani LukeSavefrogs

💭
Thinking about what to script next
View GitHub Profile
@pretty
pretty / RetryTest.php
Last active May 16, 2019 13:14 — forked from orottier/RetryTest.php
Retry function for PHP with exponential backoff
<?php
class RetryTest extends TestCase
{
public function setUp()
{
parent::setUp();
// abuse superglobal to keep track of state
$_GET['a'] = 0;
}
@ziesemer
ziesemer / ssh-ControlMaster-test.sh
Last active September 7, 2021 20:55
ssh-ControlMaster-test.sh
#!/bin/bash
# Mark Ziesemer, 2016-02-11, 2016-12-14.
# As described at https://rhn.redhat.com/errata/RHSA-2015-2088.html ,
# I'm afraid that the race condition with OpenSSH ControlMaster multiplexing is still not resolved
# in recent CentOS / Fedora releases.
# This refers to BZ#1240613 (which is apparently restricted), and is also described at
# https://access.redhat.com/solutions/1521923 (which is non-public, restricted to subscription access).
# Reported to https://bugzilla.redhat.com/show_bug.cgi?id=1308295 on 2016-02-13 .
@staticfloat
staticfloat / install_cygwin.ps1
Created September 1, 2015 15:46
Cygwin installation script
function Install-Cygwin {
param ( $CygDir="c:\cygwin", $arch="x86")
# Generate random password (forcing a non-alphanumeric at the end because of policies
$password = (([char[]]([char]'a'..[char]'z') + 0..9 | sort {get-random})[0..12] -join '') + '.'
Write-Verbose "Not-so-secret password: $password"
if(!(Test-Path -Path $CygDir -PathType Container)) {
Write-Verbose "Creating directory $CygDir"
New-Item -Type Directory -Path $CygDir -Force
@anthonyaxenov
anthonyaxenov / stacktrace.sh
Last active June 28, 2023 14:10 — forked from akostadinov/stack_trace.sh
[SHELL] Print stacktrace
# Original: https://gist.github.com/akostadinov/33bb2606afe1b334169dfbf202991d36
# The difference is that this func outputs stacktrace in reverse order (from top level to lower ones)
function print_stacktrace () {
STACK=""
local i
local stack_size=${#FUNCNAME[@]}
echo "Stacktrace:"
# skip this function and "MAIN non_file_source:0"
for (( i=$stack_size-1; i>=1; i-- )); do
local func="${FUNCNAME[$i]}"
@orottier
orottier / RetryTest.php
Last active July 21, 2023 10:10
Retry function for PHP with exponential backoff
<?php
class RetryTest extends TestCase
{
public function setUp()
{
parent::setUp();
// abuse superglobal to keep track of state
$_GET['a'] = 0;
}
@Plou
Plou / projectName.local.plou
Created June 18, 2013 21:23
a virtual host example, Access-Control-Allow-Origin set to allow any request from foreign domains
## projectName
<VirtualHost *:80>
ServerName projectName.local.plou
CustomLog "/www/.logs/projectName.local.plou-access_log" combined
ErrorLog "/www/.logs/projectName.local.plou-error_log"
DocumentRoot "/www/projectName/"
Header set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, PUT, GET, DELETE, OPTIONS"
Header always set Access-Control-Allow-Headers "Content-Type"
</VirtualHost>
@hdodov
hdodov / iframechange.js
Last active September 15, 2023 15:35
HTML iframe URL change listener for tracking when a new iframe page starts to load
function iframeURLChange(iframe, callback) {
var lastDispatched = null;
var dispatchChange = function () {
var newHref = iframe.contentWindow.location.href;
if (newHref !== lastDispatched) {
callback(newHref);
lastDispatched = newHref;
}
@rtomayko
rtomayko / ssh-persistent-control-master.md
Created June 7, 2017 19:43
10x SSH connection speedup w/ persistent control masters

SSH Persistent Control Master Config

Add to ~/.ssh/config:

Host *
  # Enable persistent connection multiplexing
  ControlMaster auto
  ControlPath ~/.ssh/-%r@%h:%p
 ControlPersist 600
@thikade
thikade / wasdecode.md
Last active November 9, 2023 15:48
WebSphere wsadmin-embedded password en/decoder

Decode WAS password using wsadmin.sh:

./wsadmin.sh -lang jython -conntype none -c 'import com.ibm.ws.security.util.PasswordDecoder as pd; pd.main(["{xor}KzosK25tbH4n"]);'

Encode WAS password using wsadmin.sh:

./wsadmin.sh -lang jython -conntype none -c 'import com.ibm.ws.security.util.PasswordEncoder as pd; pd.main(["test123!x"]);'
@refo
refo / bash-filepath-parts.md
Last active February 2, 2024 11:57
Extract file name / file path parts using bash

Extract given file path into its parts

Assuming, file passed as a parameter

path=$1

following script will extract file path into parts