Skip to content

Instantly share code, notes, and snippets.

@JimHume
JimHume / juniordevlinks.md
Last active September 13, 2017 19:30
Junior Developer Links / Reads
@JimHume
JimHume / continuous_curl.sh
Created January 30, 2018 18:43
A bash script to continuously curl a host, checking for a pattern/set of patterns in the result using grep. It prints random length noise at the end of the output to make it easier to see the text moving out of the corner of your eye--great for multiple (4) screens.
#!/bin/bash
function arg_or_default()
{
if [ -n "$1" ]; then
echo "$1"
else
echo "$2"
fi
@JimHume
JimHume / Netfilter-IPTables-Diagrams.md
Created February 8, 2018 21:36 — forked from nerdalert/Netfilter-IPTables-Diagrams.md
Linux NetFilter, IP Tables and Conntrack Diagrams

Linux NetFilter, IP Tables and Conntrack Diagrams

IPTABLES TABLES and CHAINS

IPTables has the following 4 built-in tables.

1) Filter Table

Filter is default table for iptables. So, if you don’t define you own table, you’ll be using filter table. Iptables’s filter table has the following built-in chains.

@JimHume
JimHume / Fix_Netgear_Stora.sh
Created May 20, 2018 17:46
This gist may help others who have a Netgear Stora that encounters the issue "Error message: at /var/www/admin/update.pm line 346"
#!/bin/bash
# This is the contents of the updated script:
NEW_SCRIPT=$(cat << EOF
package setup_update;
sub process {
return 'success';
}
sub display {
my $vars = shift @_;
@JimHume
JimHume / upload.sh
Last active April 16, 2019 17:30
motionEye OS Slack Upload script.
#!/bin/bash
################################################################################
# Constants
# TOKEN: Taken from an API bot
TOKEN='letters-numbers-numbers-numbersandletters'
# CHANNEL: When viewing the desired channel in a browser, this will be the last
# segment of the URL
@JimHume
JimHume / DbContextExtensions.cs
Last active October 11, 2019 23:38
Get the full path to a SQL CE database file
public static class DbContextExtensions
{
/// <summary>
/// Resolve the connection string for the given <see cref="DbContext"/>. This resolves variables in the
/// connection string to their local values. E.g. "Data Source=|DataDirectory|\Database.sdf" will resolve
/// to "C:\ProgramData\MyApp\Database.sdf".
/// </summary>
/// <param name="dbContext"><see cref="DbContext"/></param>
/// <returns><see cref="string"/>: The fully-resolved connection string.</returns>
public static string GetResolvedConnectionString(this DbContext dbContext)
@JimHume
JimHume / Get-CurrentClusterToken.ps1
Created October 20, 2020 00:00
Kubernetes dashboard: get current admin token, copy it to the clipboard, port-forward the dashboard locally, then launch in a browser.
clear
# Find the current cluster admin user token
$clusterName = $(kubectl config current-context)
$contextUser = $(kubectl config view -o jsonpath="{.contexts[?(@.name == '$clusterName')].context.user}")
$token = $(kubectl config view -o jsonpath="{.users[?(@.name == '$contextUser')].user.token}")
# Copy the admin token to the clipboard
Set-Clipboard $token
# Launch the dashboard and open it in a browser
@JimHume
JimHume / LaunchKubernetesDashboard.ps1
Created September 14, 2022 00:14
Launch the currently-active-kubernetes-cluster's dashboard while copying the token out of the kube config. This gets around the "REDACTED" issue with kubectl taking out the certs & tokens when asking for details directly out of the config.
# Note: One would want to wrap this in a batch file that contains this:
# PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '.\LaunchKubernetesDashboard.ps1'"
# (or whatever you name the file)
clear
# Get the currently-active cluster name
$clusterName = $(kubectl config current-context)
# Get the user name for the active context
$contextUser = $(kubectl config view -o jsonpath="{.contexts[?(@.name == '$clusterName')].context.user}")