Skip to content

Instantly share code, notes, and snippets.

@webcoyote
webcoyote / get-files-in-array.sh
Created February 7, 2020 23:36
Bash script to aggregate files into an array for use in a command
#!/usr/bin/env bash
set -euo pipefail
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
declare -a LIBS
while IFS= read -rd $'\0' LIB; do
LIBS+=("$LIB")
done < <(find "$SCRIPT_DIR/bin" -type f -iname '*.dll' -print0)
echo "Count: ${#LIBS[@]}"
@webcoyote
webcoyote / keybase.md
Created April 24, 2019 19:47
Keybase proof

Keybase proof

I hereby claim:

  • I am webcoyote on github.
  • I am netcoyote (https://keybase.io/netcoyote) on keybase.
  • I have a public key ASBunOu0oWmW7hRupsMmS7VD-Y2L0T-ij3lRWlNlpHpGXwo

To claim this, I am signing this object:

@webcoyote
webcoyote / planck-self-referencing-script.sh
Created January 30, 2019 02:54
Planck (ClojureScript) script demonstrating difficulty of "self-referencing scripts"
#!/usr/bin/env bash
"exec" "plk" "-Sdeps" "{:deps {org.clojure/tools.cli {:mvn/version \"0.4.1\"}}}" "-Ksf" "${BASH_SOURCE[0]}" "--script" "${BASH_SOURCE[0]}" "$@"
;; # This program was written to utilize the Planck ClojureScript tool and see how
;; # easy it would be to write command-line utilities.
;; #
;; # One problem I encountered: in bash, it's reasonably easy to discover where
;; # the script is located so as to perform script-relative file manipulation,
;; # like this:
;; #
@webcoyote
webcoyote / configure-firewall-example.bat
Created December 11, 2012 18:45
Windows Firewall configuration script
@echo off
::configure-firewall-example.bat
::by Patrick Wyatt 12/22/2011
::MIT License - do with as you will; no warranty
SETLOCAL EnableExtensions
if "%1" == "" (
echo Usage:
echo %0 display
echo %0 install
@webcoyote
webcoyote / connector.rb
Last active December 21, 2015 03:49
Single connection to remote server using celluloid
require 'celluloid/io'
class Connection
include Celluloid::IO
PACK_LENGTH = 'S>' # unsigned big-endian
def initialize (host, port)
@transactions = {}
@host = host
@webcoyote
webcoyote / SearchConfigFile.rb
Created May 1, 2013 22:03
Search for a configuration file in current directory upwards towards root directory the way that .gitignore and .p4config work
#!/usr/bin/env ruby
class SearchConfigFile
def self.search (filename, directory)
# Use current directory if directory not specified
directory ||= Dir.getwd
# Use expand_path to get absolute path; 1.8.7 compatible
search_up filename, File.expand_path(directory)
@webcoyote
webcoyote / KEYBOARD.md
Created February 10, 2013 06:25
Notes for fixing Windows key to be usable by xmonad desktop manager in Linux virtual machine

XMonad keyboard fix

remapping the #$#$ Windows key so it can be used in Linux VM

  1. Compile xmonad.hs to use modMask = mod3Mask ("mod3")

  2. Use SharpKeys.exe on Windows host to remap "Left Windows" key to "F15", which is unused on modern keyboards. Reboot.

  3. In Linux guest, type the "Left Windows" key. Then dmesg|tail -5 should produce output like this:

@webcoyote
webcoyote / dirglob.rb
Created February 5, 2013 21:13
Ruby directory globbing
Dir.glob(
'**/*', File::FNM_DOTMATCH
).reject { |a| a =~ /\.{1,2}$/ }.each do |f|
puts f
end
@webcoyote
webcoyote / create-or-update.sql
Created December 11, 2012 19:15
Update SQL stored procedure
-- if the stored procedure does not exist then create a placeholder
if not exists (
select * from sys.objects where object_id = OBJECT_ID(N' p_MyProc')
and type = N'P'
) then
create procedure p_MyProc as RAISERROR ('MyProc not defined', 16, 1);
grant execute on p_MyProc to SomeRole
end
-- update stored proc
@webcoyote
webcoyote / PlatformTime.cpp
Created December 11, 2012 19:06
Transaction rate-limiting
unsigned PlatformTimeMs () {
#if defined(_WINDOWS_)
return GetTickCount();
#else
#error Your implementation here
// something like clock_gettime(CLOCK_MONOTONIC, ...) for Unix/Linux
#endif
}