Skip to content

Instantly share code, notes, and snippets.

@jecxjo
jecxjo / daemonize.sh
Created January 9, 2022 05:28
Freebsd Daemonize script
#!/bin/sh
#
# Usage: daemonize.sh <pidfile> <exec> [<args>]
#
# Can be run from a cron job, will only trigger a single daemon to run
# and should restart the child daemon process if it fails.
usage() {
awk '/# Usage/{ x=1 } x==1 { print $0 } !/^#/ && x==1 { exit 0 }' $0 >&2
exit 2
@jecxjo
jecxjo / easy-shell-usage.sh
Created January 5, 2022 15:36
Easy way to print usage using awk
#!/bin/sh
#
# This is a test script
#
# Usage: easy-shell-usage.sh [<arguments>]
#
# There aren't any arguments available, but if there were they would be documented here.
# Anything in the first block of comments starting at the "Usage" line.
# Prints usage, but this comment won't be printed
@jecxjo
jecxjo / test.sh
Created April 22, 2021 19:17
Self Contained Secure Shell Script
#!/usr/bin/env bash
#
# To use, encrypt a script with openssl cli and append the contents below the
# __ARCHIVE_BELOW__ line. The current example encrypted script takes two args.
# The password is "asdf".
#
# To encrypt:
# $ openssl aes-256-cbc -a -salt -in <script name> -out <enc name>
ARCHIVE=$(awk '/^__ARCHIVE_BELOW__/ {print NR + 1; exit 0;}' "$0")
@jecxjo
jecxjo / sss.sh
Created April 22, 2021 16:26
Secure Shell Script
#!/usr/bin/env bash
usage() {
cat <<EOF
USAGE: sss.sh <script> [<args>]
To encrypt file you'll need openssl cli
$ openssl aes-256-cbc -a -salt -in <script> -out <enc script>
@jecxjo
jecxjo / README
Last active August 12, 2020 16:34
SlackBuild: racket 7.8
Racket (formerly named PLT Scheme) is a general purpose, multi-paradigm
programming language in the Lisp/Scheme family. One of its design goals is to
serve as a platform for language creation, design, and implementation. The
language is used in a variety of contexts such as scripting, general-purpose
programming, computer science education, and research. (source: Wikipedia)
racket is the command line version, drracket is the GUI-version
This SlackBuild uses the src + built packages distribution. It builds
faster as it contains platform-independent bytecode. If you wish to build
@jecxjo
jecxjo / diceware.sh
Last active June 12, 2017 22:56
A simple diceware script that includes a wordlist.
#!/bin/bash
#===============================================================================
# Copyright (c) 2017 Jeff Parent
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
@jecxjo
jecxjo / newdefect.tcl
Created September 6, 2016 16:05
New Defect Utility (todo.txt and Perforce)
# Name: New Defect Automation
# Author: Jeff Parent
# Date: 2016/08/12 20:40:03
# Changes:
# 0.5 - Added P4PORT configuration and using Promises
# 0.3 - Writes to Todo.txt and Perforce
set version "0.5"
package provide app-newdefect $version
@jecxjo
jecxjo / saltpack.vim
Created September 2, 2016 03:41
Vimscript to Read/Write Keybase's Saltpack encrypted files
" Keybase - saltpack
augroup SALTPACK
au!
" Make sure nothing is written to ~/.viminfo
au BufReadPre,FileReadPre *.saltpack set viminfo=
" No other files with unencrypted info
au BufReadPre,FileReadPre *.saltpack set noswapfile noundofile nobackup
" Reading Files, assumes you can decrypt
au BufReadPost,FileReadPost *.saltpack :%!keybase decrypt
@jecxjo
jecxjo / crypto.tcl
Created August 26, 2016 19:28
tcl/tk example AES Encryption with channels and transforms
# crypto.tcl --
#
# This file implements and example Tk applicaiton that uses
# AES encryption, Channels and Transforms.
#
# Copyright (c) 2016 Jeff Parent
#
# This code is licensed under the Creative Commons Attribution-ShareAlike 4.0
# International license (CC BY-SA 4.0).
#
@jecxjo
jecxjo / aes-example.tcl
Created August 25, 2016 21:26
AES File Encryption / Decryption in tcl with automatic base64 encoding
# Requires tcllib
package require aes
package require tcl::transform::base64
package require md5
# Make some sort of key data, 16, 24, or 32 bytes long
set key [string repeat - 16]
# Generate an IV, 16 bytes long. MD5 of clock ticks, the Proc ID, and
# a random value. Take 16 bytes.