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
@andrewrcollins
andrewrcollins / trim.awk
Created January 11, 2012 04:22
ltrim(), rtrim(), and trim() in awk
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
function trim(s) { return rtrim(ltrim(s)); }
BEGIN {
# whatever
}
{
# whatever
}
END {
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@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>
@gesquive
gesquive / self-update-script.py
Last active February 18, 2024 20:36
Stick this in a python script to self update the script from an online source
def update(dl_url, force_update=False):
"""
Attempts to download the update url in order to find if an update is needed.
If an update is needed, the current script is backed up and the update is
saved in its place.
"""
import urllib
import re
from subprocess import call
def compare_versions(vA, vB):
@swarminglogic
swarminglogic / watchfile.sh
Last active March 4, 2024 14:44
watchfile - monitor file(s) and execute a command when files are changed
#!/bin/bash
version=1.0.1
versionDate="2014-02-14"
function showHelp() {
echo "watchfile - monitor file(s)/command and perform action when changed
Possible ways of usage
----------------------------------------
// ==UserScript==
// @name GM_download emulation
// @namespace http://tampermonkey.net/
// @version 0.1
// @description emulate GM_download functionality
// @require https://github.com/eligrey/FileSaver.js/raw/master/FileSaver.js
// @match http://tampermonkey.net/empty.html
// @grant GM_xmlhttpRequest
// @copyright 2014, Jan Biniok
// ==/UserScript==
@ju2wheels
ju2wheels / docker-compose.yml
Created June 10, 2015 20:11
docker-compose reference YAML file with comments
# https://docs.docker.com/compose/yml/
# Each service defined in docker-compose.yml must specify exactly one of
# image or build. Other keys are optional, and are analogous to their
# docker run command-line counterparts.
#
# As with docker run, options specified in the Dockerfile (e.g., CMD,
# EXPOSE, VOLUME, ENV) are respected by default - you don't need to
# specify them again in docker-compose.yml.
#
service_name:
@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
@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 .
@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;
}