I hereby claim:
- I am alecthegeek on github.
- I am alecthegeek (https://keybase.io/alecthegeek) on keybase.
- I have a public key ASBFcJ6GvWTlzfOjNNAe7KUFVzmpTpq32EoKJvPjwkycvQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
#!/usr/bin/env expect -f | |
# Start the CISCO VPN client on a Mac. Adapted from | |
# https://blog.felipe-alfaro.com/2014/05/23/automating-cisco-anyconnect-secure-mobility-client-on-mac-os-x/ | |
set HOSTNAME vpn.server.com | |
set USER_NAME user.name | |
set PASSWORD password | |
spawn /opt/cisco/anyconnect/bin/vpn |
#! /usr/bin/env bash | |
if [[ -x /Applications/PaperCut\ MF/server/bin/mac/server-command && | |
-x /Applications/PaperCut\ NG/server/bin/mac/server-command ]] ; then | |
echo copies of both NG and MF installed! | |
exit 1 | |
elif [[ -x /Applications/PaperCut\ MF/server/bin/mac/server-command ]]; then | |
app_root='/Applications/PaperCut MF' | |
elif [[ -x /Applications/PaperCut\ NG/server/bin/mac/server-command ]]; then | |
app_root='/Applications/PaperCut NG' |
# Upgraded git using Homebrew and now your __git_ps1() fails. Try something like this | |
# NB Still very fragile as had embedded version no | |
# enable git programmable completion features | |
if [ -f /usr/local/etc/bash_completion.d/git-completion.bash ]; then | |
. /usr/local/etc/bash_completion.d/git-completion.bash | |
fi | |
# enable git prompt |
#!/usr/bin/env bash | |
docker container run --rm -it --user $(id -u):$(id -g) \ | |
--mount "type=bind,source=$PWD,target=/testproj" \ | |
--workdir /testproj --env HOME=/testproj/dotnetcache mcr.microsoft.com/dotnet/sdk:6.0 "$@" |
#!/usr/bin/env python3 | |
def collatz(n: int, p = True): | |
i: int = 0 | |
while n > 1: | |
if n % 2 != 0: | |
n = 3*n +1 | |
i += 1 | |
if p: print(f"{i}: {n}") |
# Bash alias to run Google gcloud via Docker | |
alias gcloud="docker run --workdir=/home/cloudsdk/work --user cloudsdk:cloudsdk \ | |
--mount type=bind,source=$PWD,target=/home/cloudsdk/work \ | |
--mount type=volume,source=gcloud_config,target=/home/cloudsdk/.config \ | |
--rm -ti gcr.io/google.com/cloudsdktool/cloud-sdk:slim gcloud" |
#!/usr/bin/env python | |
# Find cube roots. In honour of Pandrosion of Alexandria on Ada Lovelace day 2020 | |
# from https://en.wikipedia.org/wiki/Cube_root#Numerical_methods | |
# see also https://docs.python.org/3/tutorial/floatingpoint.html | |
def cubeRoot(a, epislon = 0.001): | |
''' Approximate cube roots using Halley's method |
(echo -en "blob $(wc -c < $file)\00";cat $file)|sha1sum -b | cut -d " " -f 1 | |
or of course | |
git hash-object $file |
# Git alias for next `git next` to go to next commit. Works on Powershell, brobably works on Bash as well. | |
# Useful for live code demo. See https://blog.jayway.com/2015/03/30/using-git-commits-to-drive-a-live-coding-session | |
# Info about mapfile from https://www.computerhope.com/unix/bash/mapfile.htm | |
# Needed because Git on Windows does not have access to tail (by default) | |
next = "!$SHELL -c 'git checkout $(mapfile -t < <(git rev-list HEAD..demo-end);echo -n ${MAPFILE[-1]})'" | |