Skip to content

Instantly share code, notes, and snippets.

View dhensen's full-sized avatar
🎯
Focusing

Dino Hensen dhensen

🎯
Focusing
View GitHub Profile
@dhensen
dhensen / cleanup_nmcli_connections.sh
Created June 27, 2022 21:42
Remove all nmcli connections except one
nmcli -f name connection show | grep -Ev 'Tatooine5G|NAME' | sed -e 's/[[:space:]]*$//' | tr '\n' '\0' | xargs -0 -n1 nmcli connection delete
"""The following command checks which packages have a dependency on a given package checking through all packages even though not installed locally:
pacman -Sii nodejs-lts-gallium | grep "Req" | sed -e 's/Required By : //g'
This returns a string of packages separated by spaces and some prefix.
This script does the same thing but then in python and tells you which packages you currently have installed of those.
THis is inspired by getting "warning: removing 'nodejs' from target list because it conflicts with 'nodejs-lts-gallium'" why trying to run pacman -Syu today.
The warning does not help, it should tell me where the warning is coming from.
This script told me that apm was the culprit (turned out to be implicitly installed for atom) I dont use atom, so removed atom along with all its dependencies. problem solved.
@dhensen
dhensen / new_vpn_client.sh
Created March 11, 2020 12:00
My old script to create a new .ovpn
#!/bin/sh
client=$1
if [ x$client = x ]; then
echo "Usage: $0 clientname"
exit 1
fi
easyrsa_dir="/etc/openvpn/easy-rsa"
@dhensen
dhensen / bash-history-to-zsh-history.py
Created December 7, 2018 23:39
Convert Bash history to zsh history
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Usage:
# $ cat ~/.bash_history | ./bash-history-to-zsh-history.py >> ~/.zsh_history
import sys
import time
def main():
import asyncio
async def foo():
print('hello')
tasks = [
bar(),
bar(),
bar(),
bar(),
@dhensen
dhensen / serial-readline.js
Created May 23, 2018 14:12
serially read lines via asynchronous readline interface using semaphore with capacity 1
// create a file named input containing 1, 2, 3, 4 on separate lines
// cat input | node serial-readline.js
// output (shows bot stdin and stdout):
// 1
// start handler
// end handler
// 2
// 3
// 4processing: 1
// start handler
@dhensen
dhensen / promise-with-timeout.js
Last active February 25, 2018 19:03
This retries, but the timeout only cancels the outer promise while the inner promise continues again and again.
/**
* Fake createOrder. It fails half of the time and had a random runtime between 0 and 1000 ms.
*/
async function createOrder() {
return new Promise((resolve, reject) => {
let action;
let returns;
if (Math.random() < 0.01) {
console.log('action=resolve');
@dhensen
dhensen / Jenkinsfile
Created January 10, 2018 07:02 — forked from jonico/Jenkinsfile
Example for a full blown Jenkins pipeline script with multiple stages, input steps, injected credentials, heroku deploy, sonarqube and artifactory integration, multiple Git commit statuses, PR merge vs branch build detection, REST API calls to GitHub deployment API, stage timeouts, stage concurrency constraints, ...
#!groovy
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
/*
Please make sure to add the following environment variables:
HEROKU_PREVIEW=<your heroku preview app>
HEROKU_PREPRODUCTION=<your heroku pre-production app>
HEROKU_PRODUCTION=<your heroku production app>
@dhensen
dhensen / set-ingress-class.go
Last active September 16, 2017 09:08
Default ingress-class can not be overridden
package main
import (
"flag"
"fmt"
"os"
"github.com/spf13/pflag"
)
import requests
from bs4 import BeautifulSoup
url = "http://www.nytimes.com"
r = requests.get(url)
r_html = r.text
soup = BeautifulSoup(r_html, "html.parser")
storyheadings = soup.select(".story-heading > a")