Skip to content

Instantly share code, notes, and snippets.

View bsnux's full-sized avatar
💭
👨‍💻

Arturo Fernandez bsnux

💭
👨‍💻
View GitHub Profile
@bsnux
bsnux / generate-pw.sh
Last active April 22, 2020 17:03
Generate Apache MD5 enc file with openssl for basic HTTP auth
# Reference: https://www.nginx.com/resources/wiki/community/faq/#how-do-i-generate-an-htpasswd-file-without-having-apache-tools-installed
USER="alice"
PW="the_password"
printf "$USER:$(openssl passwd -apr1 $PW)\n" >> .htpasswd
@bsnux
bsnux / list-namespaces.clj
Last active March 14, 2020 00:09
Listing all namespaces names in given cluster
(ns cleanup-wg.core
(:import [io.kubernetes.client.util ClientBuilder]
[io.kubernetes.client.util KubeConfig]
[io.kubernetes.client Configuration]
[io.kubernetes.client.apis CoreV1Api])
(:gen-class))
(defn -main
"List all namespaces on given Kubernetes cluster"
[& args]
@bsnux
bsnux / profiles.clj
Created March 9, 2020 23:08
Clojure lein profile for development
; ~/.lein/profiles.clj
{:user
{:plugins [[jonase/eastwood "0.3.10"]
[lein-cljfmt "0.6.7"]
[cider/cider-nrepl "0.24.0"]]
:dependencies [[cljfmt "0.6.7"]]}}
@bsnux
bsnux / .editorconfig
Created February 28, 2020 20:13
Editor config
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
[Jenkinsfile]
indent_size = 4
indent_style = space
[*.groovy]
@bsnux
bsnux / test-run.el
Created February 27, 2020 19:09
Learning Emacs LISP
;;; package --- Testing script from emacs
;;; Commentary:
;;; Code:
;; $ emacs --script test.el
(message "Hello World!")
(defun mytest2()
(message "hi!"))
@bsnux
bsnux / ts-starter.sh
Created January 3, 2020 19:57
Simple boilerplate generator for TypeScript projects
#!/bin/bash
#--
# Simple boilerplate generator for TypeScript projects
#--
project_name=$1
main_file=${2:-index.ts}
mkdir $project_name && cd $project_name
npm init -y
@bsnux
bsnux / basics.clj
Last active March 4, 2020 01:15
Simple Clojure introduction
;;
;; Clojure is a Lisp family functional programming language developed for the JVM
;;
;; It is better to have 100 functions operate on one data structure than 10 functions on 10 data structures.
;; —Alan Perlis
;;
;; Reference: https://www.braveclojure.com/
;;
; The first call in a file should be ns, to set the namespace
@bsnux
bsnux / perl-oneliners.sh
Last active November 13, 2019 18:05
Useful Perl oneliners
#--
# The -p option takes each line of the standard input (STDIN) and assigns that line to the variable $_,
# then executes the script on that line. The $_ variable is a special variable which is set each
# iteration of the loop. When your script is complete it prints out the value of $_ to standard
# output (STDOUT). If there are command line arguments, -p will use those arguments as filenames and
# perform the same steps on each line of those files.
#
# The -n option is similar to -p except it does not print every line to the standard output.
#--
@bsnux
bsnux / count-docker-layers.sh
Created August 19, 2019 22:05
Count docker images layers
#!/bin/bash
image=$1
usage () {
echo -n "Usage: $0 <full-image-URL>
Count number of layers of given Docker image
Options:
-h, --help Display this help and exit
@bsnux
bsnux / py-compile.sh
Created July 18, 2019 17:25
Generates a binary file for Linux from a Python source
#!/bin/zsh
#--------------------------------------------------------------
# py-compile.sh
#
# Generates a binary file for Linux from a Python source
#
# Usage: py-compile.sh myfile.py
#--------------------------------------------------------------
set -e