Skip to content

Instantly share code, notes, and snippets.

Avatar
🌪️
🐧

nexus166

🌪️
🐧
  • Earth
View GitHub Profile
@nexus166
nexus166 / generate_directory_index_caddystyle.py
Created Jan 22, 2021 — forked from glowinthedark/generate_directory_index_caddystyle.py
Generate directory index (recurse subfolders with `-r` or `--recursive`). Use `-h` or `--help` for all options
View generate_directory_index_caddystyle.py
#!/usr/bin/env python3
# ---
# Copyright 2020 glowinthedark
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
View openwrt-sim7600-uqmi-startup.sh
#!/bin/bash -x
sleep 15
_uqmi="/sbin/uqmi"
ifdown WWAN || true
_cleanup() {
/usr/bin/killall "${_uqmi}" 2>/dev/null || true
for i in $(/bin/ps www | /usr/bin/awk '/uqmi/ && /cdc-wdm0/ && !/awk/ {print $1}'); do
View cryptpv.sh
#!/usr/bin/env bash
set -xeuo pipefail
DISK="${1}"
_DISKNAME="$(basename "${DISK}")"
openssl rand 4096 >"${_DISKNAME}.key"
yes YES | cryptsetup luksFormat -d "${_DISKNAME}.key" "${DISK}" || true
View debian-unattended-upgrades.md

install packages

apt install unattended-upgrades apt-config-auto-update

configure

cat <<'EOF' | tee /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Origins-Pattern {
        "origin=Debian,codename=${distro_codename},label=Debian";
View mongodb-replicaset-reset.md
cfg = rs.conf()
cfg.members[0]["host"] = "[insert_correct_hostname_or_ip]:27017"
rs.reconfig(cfg)
@nexus166
nexus166 / dict2json.sh
Last active Aug 12, 2020
convert bash arrays to json
View dict2json.sh
#!/usr/bin/env bash
dict2json() {
local _data=""
trap 'if [[ -n "${_data}" ]]; then printf "{%s}" "${_data%?}" | jq -arc .; fi' RETURN
case "${#@}" in
0)
return
;;
1)
View radiotelephony_spelling.sh
#!/usr/bin/env bash
declare -A CHART=(
["a"]="alpha" ["b"]="bravo" ["c"]="charlie"
["d"]="delta" ["e"]="echo" ["f"]="foxtrot"
["g"]="golf" ["h"]="hotel" ["i"]="india"
["j"]="juliet" ["k"]="kilo" ["l"]="lima"
["m"]="mike" ["n"]="november" ["o"]="oscar"
["p"]="papa" ["q"]="quebec" ["r"]="romeo"
["s"]="sierra" ["t"]="tango" ["u"]="uniform"
@nexus166
nexus166 / chunk_split.go
Created Jun 17, 2020
split and merge []byte in go
View chunk_split.go
package main
import (
"fmt"
)
func main() {
s := "He turned in the research paper on Friday; otherwise, he would have not passed the class."
fmt.Printf("%s\nlenght:%d\n", s, len(s))
View rotateString.go
func rotateString(s string, n int, encdec bool) (string, error) {
l := len(s)
if l < 1 {
return "", fmt.Errorf("empty input")
}
if n < 1 || n > 6 {
return "", fmt.Errorf("invalid shift n %d", n)
}
var out string
switch encdec {
View bitstring.go
package main
import (
"bytes"
"fmt"
"os"
"strings"
"strconv"
)