Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖
Dem keyboards don't go click click on their own you know

Alec Clews alecthegeek

🤖
Dem keyboards don't go click click on their own you know
View GitHub Profile
@alecthegeek
alecthegeek / gcloud.sh
Created Jun 1, 2021
Bash alias to run Google gcloud via Docker
View gcloud.sh
# 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"
View adaLovelaceDay2020.py
#!/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
@alecthegeek
alecthegeek / .gitconfig
Last active Aug 23, 2020
Git alias for next `git next` to go to next commit. Works on Powershell
View .gitconfig
# 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]})'"
@alecthegeek
alecthegeek / mv-branch.sh
Created Jul 29, 2020
Move branches names on a local repo and push change to the remote. Defaults master -> main
View mv-branch.sh
#!/bin/bash
oldb="${1:-master}"
newb="${2:-main}"
git pull --all
git checkout $oldb
View gist:661f0ba3d157ebd7843cb07d2ff2fa87
FROM debian:buster-slim
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y \
nginx
View fedora notes
1. Package manager CLI is `dnf`
2. ALL the hardware works. Wifi, bt, function buttons
3. BT pairing and tethering was easy to set up
4. BT headphones took a few attempts to work
4. Good battery management
Snap:
Many apps (e.g. Spotify, Slack, ..) need to be installed with Snap
@alecthegeek
alecthegeek / run-dot-net-dev
Created Mar 14, 2020
Runs a Dot net development env
View run-dot-net-dev
#!/usr/bin/env bash
docker container run --rm -it --user 1000:1000 \
--mount type=bind,source=$PWD,target=/testproj \
--workdir /testproj --env HOME=/testproj/dotnetcache mcr.microsoft.com/dotnet/core/sdk:3.1 "$@"
@alecthegeek
alecthegeek / json.ps1
Last active Apr 5, 2019
Json on the Powershell command line
View json.ps1
# Run some program that needs to supply valid json strings (that contain `"`)
# note the use of backtick to escape newlines
# AND NOTE that from --% onwards the backtick no longer works. It must be on one line!
# This information helped me
# https://ss64.com/ps/syntax-esc.html
& 'C:\Program Files\<app>\<program>.exe' `
@alecthegeek
alecthegeek / profile.ps1
Last active Mar 14, 2019 — forked from sixeyed/profile.ps1
PowerShell profile with aliases for common Docker commands
View profile.ps1
function Remove-StoppedContainers {
docker container rm $(docker container ls -q)
}
function Remove-AllContainers {
docker container rm -f $(docker container ls -aq)
}
function Get-ContainerIPAddress {
param (