Skip to content

Instantly share code, notes, and snippets.

View Luit's full-sized avatar

Luit van Drongelen Luit

View GitHub Profile
@Luit
Luit / netlify-dns.sh
Created July 23, 2018 19:58
Run with EXEC_PATH=/path/to/netlify-dns.sh and a file in the same directory called netlify-dns.sh.token containing a personal access token from https://app.netlify.com/account/applications/personal
#!/bin/bash
set -e
set -o pipefail
# Sanity checks to fail early.
command -V jq >/dev/null
command -V curl >/dev/null
if [ $# -ne 4 ]; then
@Luit
Luit / 99-wifi-auto-switch.sh
Created July 19, 2017 09:36
/etc/NetworkManager/dispatcher.d/99-wifi-auto-switch.sh
#!/bin/bash
if [ "${1:0:2}" = "en" ]; then
case "$2" in
up)
nmcli r wifi off
;;
down)
nmcli r wifi on
;;
package main
import (
"log"
"os"
"golang.org/x/net/html"
)
func elem(data string) *html.Node {
package main
import (
"log"
"os"
"golang.org/x/net/html"
)
func main() {
@Luit
Luit / .bashrc-snippet
Last active August 29, 2015 14:27
check_docker_memory function
function check_docker_memory {
for id in $(docker ps -q --no-trunc); do
name=$(docker inspect -f "{{.Name}}" $id)
echo $(numfmt --to=iec --suffix=B $(cat /sys/fs/cgroup/memory/system.slice/docker-$id.scope/memory.usage_in_bytes)) ${name#/}
done
}
@Luit
Luit / kseD.ino
Last active August 29, 2015 14:16
// kinda smart ergonomic Desk, or kseD for short, is a project to make my
// no-frills ergonomic desk a bit more special.
/*
Serial commands:
E <upper> <lower>
Read value from EEPROM (might disappear once testing is done)
G <upper> <lower>

Keybase proof

I hereby claim:

  • I am Luit on github.
  • I am luit (https://keybase.io/luit) on keybase.
  • I have a public key whose fingerprint is 52BD 2314 CA93 839B 2A50 1397 984B E3B2 71A8 8C47

To claim this, I am signing this object:

@Luit
Luit / utils.go
Last active December 24, 2015 23:49
package utils
func Slugify(title string) string {
var slug []byte
for _, x := range title {
switch {
case ('a' <= x && x <= 'z') || ('0' <= x && x <= '9'):
slug = append(slug, byte(x))
case 'A' <= x && x <= 'Z':
#!/usr/bin/env python
import datetime
import twitter
OAUTH_T = '' # You can't have my OAuth secrets
OAUTH_TS = ''
OAUTH_CK = ''
OAUTH_CS = ''
@Luit
Luit / gist:4244643
Created December 9, 2012 12:23
What the hell, Chromium!?
luit@xps14:~$ free -m # My laptop feels sluggish
total used free shared buffers cached
Mem: 3836 3644 191 0 10 498
-/+ buffers/cache: 3135 701
Swap: 8190 1031 7159
luit@xps14:~$ free -m # I think it's Chromium, let's shut that thing down
total used free shared buffers cached
Mem: 3836 1246 2589 0 12 426
-/+ buffers/cache: 808 3028
Swap: 8190 337 7853