Skip to content

Instantly share code, notes, and snippets.

Avatar
🦧

Adam Stokes adam-stokes

🦧
View GitHub Profile
@adam-stokes
adam-stokes / Json.hx
Created Feb 10, 2022 — forked from RealyUniqueName/Json.hx
Sample PHP externs for Haxe
View Json.hx
//You can use any package name here.
//It's not required to match the namespace of php file.
package;
import php.NativeStructArray;
typedef EncodingOptions = {
?prettyPrint:Bool,
?enableJsonExprFinder:Bool,
}
View password_generator.py
#!/usr/bin/env python3
"""
Password maker
https://xkcd.com/936/
This is a script which can generate random passwords for you by selecting from a file which contains seed words
"""
import argparse
import random
import re
@adam-stokes
adam-stokes / bb-usage.md
Created Aug 26, 2021
Example bb.end with print usage
View bb-usage.md

helper/cli.clj

(ns helper.cli
  (:require [clojure.edn :as edn]
            [clojure.string :as str]
            [babashka.fs :as fs]
            [babashka.tasks :refer [shell current-task run]]
            [lread.status-line :as status]))
@adam-stokes
adam-stokes / mkjail.sh
Created Aug 24, 2021 — forked from pixelomer/mkjail.sh
Create a macOS chroot jail with GNU bash and utilities
View mkjail.sh
#!/usr/bin/env sh
#############################################
# WARNING #
# No more commits are going to be made to #
# this gist. Please get the latest script #
# from the new repository: #
# https://github.com/pixelomer/macos-mkjail #
#############################################
@adam-stokes
adam-stokes / programatic_tests.go
Created Jun 24, 2021 — forked from vaskoz/programatic_tests.go
Run golang tests programatically
View programatic_tests.go
package main
import (
"flag"
"fmt"
"testing"
)
func Test1(t *testing.T) {
if 1+2 != 3 {
@adam-stokes
adam-stokes / retry.sh
Created Jul 16, 2020 — forked from sj26/retry.sh
Bash retry function
View retry.sh
# Retry a command up to a specific numer of times until it exits successfully,
# with exponential back off.
#
# $ retry 5 echo Hello
# Hello
#
# $ retry 5 false
# Retry 1/5 exited 1, retrying in 1 seconds...
# Retry 2/5 exited 1, retrying in 2 seconds...
# Retry 3/5 exited 1, retrying in 4 seconds...
View gist:569072af88dab297de554d2436e5ddd6
cat <<EOF> profile-update.yaml
config: {}
description: Default LXD profile - updated
devices:
eth0:
name: eth0
parent: lxdbr0
nictype: bridged
type: nic
root:
@adam-stokes
adam-stokes / commands-channel.go
Created Jan 28, 2020 — forked from proudlygeek/commands-channel.go
Golang Commands in Goroutines
View commands-channel.go
package main
import (
"fmt"
"log"
"os/exec"
"runtime"
)
type Worker struct {
View gist:433899ec9c068d3fb802b293d8a440ad
for row in $(echo "$(sudo lxc list --format json)" | jq -r '.[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
sudo lxc delete --force $(_jq '.name')
done