Skip to content

Instantly share code, notes, and snippets.

View ben-z's full-sized avatar
🦄
🚀

Ben Zhang ben-z

🦄
🚀
View GitHub Profile
@ben-z
ben-z / sys-info.sh
Created June 10, 2021 08:18
Print system info
#!/bin/bash
#SBATCH --time=0-00:01:00 # time (DD-HH:MM:ss)
# Print system info (useful on shared HPCs)
# The example header is for running on Compute Canada
# https://docs.computecanada.ca/wiki/Running_jobs
echo "------ Gathering System Info"
set -x
hostname
@ben-z
ben-z / convert-to-valid-local-unicast-mac.sh
Last active June 5, 2021 22:50
MAC Address Generator (Valid unicast locally administered address)
# MAC Address Generator
# Generates valid unicast locally administered addresses by
# setting bit 2 of the first byte and clearing bit 1 of the first byte.
# Documentation: http://www.noah.org/wiki/MAC_address
# Script URL: https://gist.github.com/ben-z/3b18d1608868e6abf2212a435a216803
# https://stackoverflow.com/a/3265767/4527337
function prettyprintmac {
echo $1 | sed -e 's/../&:/g' -e 's/:$//'
}
@ben-z
ben-z / K3sInstallationNotes.md
Last active August 2, 2022 12:43
K3s Installation Notes

K3s Installation Notes (for running Gitlab Runner)

Install k3s master and expose api:

curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server --write-kubeconfig-mode 644 --bind-address 0.0.0.0" sh -

The --write-kubeconfig-mode 644 gives /etc/rancher/k3s/k3s.yaml group and world read permissions so that we can run kubectl without sudo. The INSTALL_K3S_EXEC argument can be modified at /etc/systemd/system/multi-user.target.wants/k3s.service.

@ben-z
ben-z / keybase.md
Created April 24, 2015 00:57
Keybase proof

Keybase proof

I hereby claim:

  • I am ben-z on github.
  • I am benzhang (https://keybase.io/benzhang) on keybase.
  • I have a public key whose fingerprint is C1E2 F7E1 7F23 A2FE C8C7 A7A7 9D94 E011 FF98 B78F

To claim this, I am signing this object:

@ben-z
ben-z / css-login.html
Last active August 29, 2015 14:18
Simple Log In Form with css. Preview on Codepen: http://codepen.io/anon/pen/azrmoB
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="author" content="http://github.com/ben-z/">
<meta name="license" content="ISC">
<title>Log In</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
@ben-z
ben-z / HHVMErrorHandler.php
Last active August 7, 2016 15:07
HHVM Error Handling - Error display in browser
<?php
/**
* Custom error handling for hhvm
* Implemented in EPSInventory-API(https://github.com/epsclubs/EPSInventory-API) on Jan 5, 2015
* Referenced from: http://stackoverflow.com/questions/24524222/display-fatal-notice-errors-in-browser
*/
// Usage: Call `set_error_handler(error_handler);` at the top of any php or hh file running on hhvm
set_error_handler(error_handler);