Skip to content

Instantly share code, notes, and snippets.

View falzm's full-sized avatar
🙃

Marc Falzon falzm

🙃
View GitHub Profile
@falzm
falzm / mkcd.bash
Created March 3, 2021 08:51
Simple Bash function to create a directory and cd to it immediately. Creates a temporary directory by passing flag "-t".
mkcd() {
local dir=""
while getopts "ht" c
do
case $c in
t) dir=$(mktemp -d) ;;
h|?) echo "mkcd [-t] [DIRECTORY]" ; return ;;
esac
done
shift $((OPTIND-1))
@falzm
falzm / .json
Last active July 22, 2020 18:56
Top 10 longest album durations (fixed)
{
"took" : 22,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 8392,
@falzm
falzm / itunes2json.py
Last active March 8, 2020 17:09
Convert iTunes exported library to JSON
#!/usr/bin/env python
from __future__ import print_function
from pprint import pprint
import json
import plistlib as plist
import sys
package main
import (
"bufio"
"bytes"
"fmt"
"net/http"
"net/http/httputil"
"os"
)
package main
import (
"log"
"net"
"os"
"time"
)
var (
@falzm
falzm / untag.go
Created May 18, 2019 08:27
Strip all ID3 tags from an MP3 file
package main
import (
"os"
"github.com/bogem/id3v2"
)
func main() {
tag, err := id3v2.Open(os.Args[1], id3v2.Options{Parse: true})
@falzm
falzm / tf_targeted_destroy_bug.tf
Created May 7, 2019 09:20
Terraform sample configuration illustrating a bug with targeted "destroy" command
# This example uses the Exoscale provider:
# https://github.com/exoscale/terraform-provider-exoscale/
locals {
zone = "ch-gva-2"
key_pair = "default"
hostnames = [
"ch2771-test1",
"ch2771-test2",
@falzm
falzm / .json
Created October 3, 2015 18:46
10 Most played tracks
{
"took" : 16,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 8486,
@falzm
falzm / commonlog2iso8601.go
Created November 2, 2014 16:42
Convert Nginx' "time_local" to "time_iso8601" date formats
package main
import "fmt"
import "time"
func main() {
commonlogDateFormat := "2/Jan/2006:15:04:05 -0700"
iso8601DateFormat := "2006-01-02T15:04:05-07:00"
parsedDate, err := time.Parse(commonlogDateFormat, "18/Oct/2014:08:53:14 +0200")
@falzm
falzm / collectd_mariadb_tablestats.py
Last active April 13, 2017 14:41
collectd-python module for reading MariaDB user statistics
#!/usr/bin/python
# -*- coding: utf-8 -*-
# collectd-python module for reading MariaDB user statistics
# Author: Marc Falzon
#
# Requirements:
# * MariaDB >= 5.2.0 with user statistics enabled
# (see https://mariadb.com/kb/en/mariadb/user-statistics/)
# * collectd compiled with Python module