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 / make_backup_vbox_bootable.sh
Created March 24, 2016 22:35
shell script to make my backup bootable when converted to a virtualbox image
#!/bin/sh
mount /dev/sda1 /mnt
arch-chroot /mnt /usr/bin/rm /etc/vconsole.conf
arch-chroot /mnt /usr/bin/pacman -S --noconfirm syslinux
arch-chroot /mnt /usr/bin/syslinux-install_update -i -a -m
arch-chroot /mnt /usr/bin/sed -i.bak s/sda3/sda1/g /boot/syslinux/syslinux.cfg
rm /mnt/etc/fstab
echo "tmpfs /tmp tmpfs nodev,nosuid 0 0" > /mnt/etc/fstab
echo "/dev/sda1 / ext4 defaults,noatime 0 1" >> /mnt/etc/fstab
@dhensen
dhensen / collegerama.sh
Last active June 2, 2016 12:50 — forked from mnstrspeed/collegerama.sh
Download video lectures from TU Delft Collegerama (december 2015). Requires `wget`, `curl`, and `jq` (available in Ubuntu/Debian repositories).
#!/bin/bash
# resource ID of the video, can be obtained from the video URL:
# https://collegerama.tudelft.nl/Mediasite/Play/485dbc9fac81446bae6b2ba2fe0571ac1d?catalog=cf028e9a-2a24-4e1f-bdb5-2ace3f9cd42d
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
id=$1
folder=$2
if [ -f $2 ]; then
echo "folder $2 already exists, skipping"
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")
@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"
)
@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 / 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 / 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
import asyncio
async def foo():
print('hello')
tasks = [
bar(),
bar(),
bar(),
bar(),
@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():
@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"