Skip to content

Instantly share code, notes, and snippets.

@jrosco
jrosco / self-signed-certificate-with-custom-ca.md
Created September 4, 2020 00:26 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@jrosco
jrosco / expbackoff.sh
Created August 18, 2020 00:37 — forked from nathforge/expbackoff.sh
Exponential backoff in Bash
expbackoff() {
# Exponential backoff: retries a command upon failure, scaling up the delay between retries.
# Example: "expbackoff my_command --with --some --args --maybe"
local MAX_RETRIES=${EXPBACKOFF_MAX_RETRIES:-8} # Max number of retries
local BASE=${EXPBACKOFF_BASE:-1} # Base value for backoff calculation
local MAX=${EXPBACKOFF_MAX:-300} # Max value for backoff calculation
local FAILURES=0
while ! "$@"; do
FAILURES=$(( $FAILURES + 1 ))
if (( $FAILURES > $MAX_RETRIES )); then
@jrosco
jrosco / gist:f0ef92d4e1dba79f185d05acd18ed925
Created July 25, 2017 08:56 — forked from dc2447/gist:3335099
akamai - Test if an asset is cached TCP_HIT or uncached TCP_MISS
curl -s -I -H "Pragma: akamai-x-cache-on" http://images.apple.com/ipad/images/product_title.png | grep X-Cache:
@jrosco
jrosco / rotate_desktop.sh
Created May 24, 2016 15:24 — forked from mildmojo/rotate_desktop.sh
Script to rotate the screen and touch devices on modern Linux desktops. Great for convertible laptops.
#!/bin/bash
#
# rotate_desktop.sh
#
# Rotates modern Linux desktop screen and input devices to match. Handy for
# convertible notebooks. Call this script from panel launchers, keyboard
# shortcuts, or touch gesture bindings (xSwipe, touchegg, etc.).
#
# Using transformation matrix bits taken from:
# https://wiki.ubuntu.com/X/InputCoordinateTransformation
@jrosco
jrosco / yoga-auto-rotate
Created May 22, 2016 09:26 — forked from emiller/yoga-auto-rotate
Lenovo Yoga 13 tablet mode / auto rotation script (ubuntu/debian)
#!/bin/bash
#
# yoga-auto-rotate -- ghetto-style tablet mode, with keyboard and all.
#
# Simple little script that will detect an orientation change for a
# Lenovo Yoga 13 (very hackily) and adjust the active display's
# orientation and disable/enable the touchpad as necessary.
#
# The Yoga 13 will emit keycode `e03e` at one second intervals
# when the screen is flipped into tablet mode. Since this keycode
Note 1: The following CQ curl commands assumes a admin:admin username and password.
Note 2: For Windows/Powershell users: use two "" when doing a -F cURL command.
Example: -F"":operation=delete""
Note 3: Quotes around name of package (or name of zip file, or jar) should be included.
Uninstall a bundle (use http://localhost:4505/system/console/bundles to access the Apache Felix web console)
curl -u admin:admin -daction=uninstall http://localhost:4505/system/console/bundles/"name of bundle"
Install a bundle
curl -u admin:admin -F action=install -F bundlestartlevel=20 -F
@jrosco
jrosco / progress_bar.rb
Created March 24, 2016 04:39 — forked from kuntoaji/progress_bar.rb
Simple progress bar script without Gem using Ruby.
#!/usr/bin/env ruby
progress = 'Progress ['
1000.times do |i|
# i is number from 0-999
j = i + 1
# add 1 percent every 10 times
if j % 10 == 0
@jrosco
jrosco / osx_socks.py
Created October 13, 2015 09:23 — forked from michaelballantyne/osx_socks.py
Yet another Mac SSH SOCKS proxy script. This one handles connection failure properly.
#!/usr/bin/env python
# Public domain.
"""A script to establish an SSH SOCKS proxy and enable it in the OS X network configuration.
Cleanly handles failure to connect. Kills ssh and removes network configuration on CTRL-C.
First argument gives the hostname for use with ssh."""
import subprocess, sys, signal
proxy_command_base = ['networksetup', '-setsocksfirewallproxystate', 'Wi-Fi']
@jrosco
jrosco / rds.sh
Last active September 5, 2015 06:00 — forked from onyxraven/rds.sh
Amazon RDS Performance Tuning Settings
#XLarge DBInstanceClassMemory = 15892177440 = 14.8GB
#/32 = 496630545 = 473MB
#/64 = 248315272 = 236MB
#/128 = 124157636 = 118MB
#/256 = 62078818 = 59MB
#/512 = 31039409 = 29MB
#/12582880 = 1263 #default same divisor as max_connections = 4041.6MB = 4237924762
#/25165760 = 623 # half of max_connections = 1993.6MB
#/50331520 = 315 # quarter of max_connections = 1008MB = 1056964608
#*(3/4) #default innodb pool size = 11922309120
@jrosco
jrosco / tmux.conf
Last active August 29, 2015 14:24 — forked from spicycode/tmux.conf
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000