Skip to content

Instantly share code, notes, and snippets.

View mciverza's full-sized avatar

Andrew Mac mciverza

View GitHub Profile
@billimek
billimek / rclone-sync.service
Created November 19, 2020 12:55
rclone/borg backups to backblaze b2
[Unit]
Description=Sync files using rclone
[Service]
Type=oneshot
User=root
ExecStart=/root/backup/rclone_borg_sync.sh
@xandout
xandout / README.md
Last active March 9, 2024 17:42
Kubernetes DaemonSet that enables a direct shell on each Node using SSH to localhost

Getting a shell on each node

I run several K8S cluster on EKS and by default do not setup inbound SSH to the nodes. Sometimes I need to get into each node to check things or run a one-off tool.

Rather than update my terraform, rebuild the launch templates and redeploy brand new nodes, I decided to use kubernetes to access each node directly.

Alternative option

https://github.com/alexei-led/nsenter

@dbrandman
dbrandman / RaspberryPiAsAService.md
Last active June 19, 2020 13:51
Raspberry Pi as a service

Raspberry Pi Zero as a Service

Problem setup

A friend of mine was spending about an hour a day performing manual data entry for his daily appointments. His administrative assistant would book appointments using commercial (and rather expensive) software. The software did not provide a straightforward method of exporting the appointment information; however, it did allow the admin assistant to print the appointments as a PDF document. My friend would then read paper-printed PDF documents and the fields into an Excel spreadsheet. This method was error-prone and tedious, and took him considerable time (since he wasn't a fast keyboard user to begin with).

My goal was to automate his workflow, and to produce a .csv file that he could easily incorporate into his database.

Constraints

@arnauldvm
arnauldvm / .gitconfig
Last active January 27, 2024 10:00
Git sync all local tracking branches with remotes
[alias]
tracking = "!f() { git for-each-ref --format '%(refname:short):%(upstream:short)' 'refs/heads' | egrep -v ':$'; }; f"
is-clean-workdir = "!f() { git diff --stat --exit-code || { echo \"Workdir dirty\"; exit 1; }; }; f"
is-clean-index = "!f() { git diff --stat --cached --exit-code || { echo \"Index dirty\"; exit 2; }; }; f"
is-clean = "!f() { git is-clean-workdir && git is-clean-index; }; f"
co-merge = "!f() { local=\"$1\"; remote=\"$2\"; git checkout \"$local\"; git merge --ff-only \"$remote\"; }; f"
current-branch = rev-parse --abbrev-ref HEAD
sync = "!f() { git is-clean || { echo Aborting sync.; exit 1; }; current=$(git current-branch); git fetch --all; git tracking | while IFS=: read local remote; do echo \"Merging $local with $remote\"; git co-merge \"$local\" \"$remote\"; done 3>&1 1>&2 2>&3 | egrep -i --color 'fatal|$' 3>&1 1>&2 2>&3; git checkout \"$current\"; }; f"
@rajatchopra
rajatchopra / windows setup
Last active June 19, 2018 11:48
Windows 1709 setup for kubernetes
# Allow TLS
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
# Download OpenSSH
curl -o OpenSSH-Win64.zip https://github.com/PowerShell/Win32-OpenSSH/releases/download/v7.6.0.0p1-Beta/OpenSSH-Win64.zip
# Create Unzip function:
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
@abn
abn / Jenkinsfile
Created November 28, 2017 23:06
Jenkinsfile: OpenShift podTemplate example
// this currently is restricted on OpenShift Online, however is possible on OSD/OCP clusters
// we create a dotnet builder pod using the provided jenkins slave image for executing dotnet commands in
podTemplate(
label: 'dotnet-build-pod', cloud: 'openshift',
containers: [
containerTemplate(
name: 'dotnet-build-pod', image: 'registry.access.redhat.com/dotnet/dotnet-20-jenkins-slave-rhel7:latest'
)
]) {
node('dotnet-build-pod-x') {
@abn
abn / keycloak-fetch-token-postman-pre-request.js
Created October 12, 2017 13:02
A postman pre-request script to fetch a valid token from Red Hat SSO (Keycloak) and set it to a template variable to use in request headers.
// modify these configurations to work with your environment
var server = "https://sso.example.com";
var realm = "realm";
var resource = "client";
var username = "username";
var password = "url encoded password";
var url = `${server}/auth/realms/${realm}/protocol/openid-connect/token`;
var data = `grant_type=password&client_id=${resource}&username=${username}&password=${password}`;
@jessfraz
jessfraz / boxstarter.ps1
Last active April 11, 2024 16:02
Boxstarter Commands for a new Windows box.
# Description: Boxstarter Script
# Author: Jess Frazelle <jess@linux.com>
# Last Updated: 2017-09-11
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
# Run this boxstarter by calling the following from an **elevated** command-prompt:
@samjonester
samjonester / How.md
Last active May 23, 2022 11:36
Tmate + Tmux pairing!

Tmate + Tmux pairing

Tmate is used as the "free reverse ssh tunnel". It is not super secure because a key is not required to connect, but it sure is conventient. Tmux is used inside the Tmate session to share multiple terminal windows


Here's the situation.

You've createe a new tmux session where you will do your work named foo.

@mciverza
mciverza / git_sparse_checkout.md
Last active May 26, 2017 08:31
Git sparse checkout

sparse checkout in git

Downloading only part of a git repo, e.g one subfolder, is called a sparse checkout, or sparse clone

The steps to do a sparse checkout are as follows:

  • Start with an empty git repository: git init <repo_name>
  • Enter that directory: cd <repo_name>
  • Configure the remote repo address: git remote add -f origin <url_of_remote_repo>
  • Configure git to enable sparse: git config core.sparsecheckout true