Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Alexander Morley alexmorley

🏠
Working from home
View GitHub Profile
@alexmorley
alexmorley / rge
Created Jul 21, 2020
Ripgrep then search / edit
View rge
#!/bin/sh
exec vim +/"${@: -1}" -p $(rg -l "$@")
View rge
#!/bin/sh
exec vim +/"${@: -1}" -p $(rg -l "$@")
@alexmorley
alexmorley / triangle.py
Last active Apr 15, 2019
Python class to fill in missing angles and vertices of a triangle
View triangle.py
import math
import itertools
from operator import add
from functools import reduce
import numpy as np
from scipy import stats as st
import matplotlib.pyplot as plt
class Vertex:
@alexmorley
alexmorley / patches.py
Created Mar 28, 2019
Adding commits to a repo from another with unrelated commit histories
View patches.py
# First do:
# git format-patch $commit_id..HEAD
# edit this script to only include commits that change watchfile*
# *note that commits that include this file AND alter other files will also be included
# then run this script
# then run ./process_patches.py | xargs git am
import os
import sys
watchfile = 'chapters/testing.md'
View install_dnf_c7.sh
## Warning there are potential security issues with this version
wget http://springdale.math.ias.edu/data/puias/unsupported/7/x86_64/dnf-conf-0.6.4-2.sdl7.noarch.rpm
wget http://springdale.math.ias.edu/data/puias/unsupported/7/x86_64//dnf-0.6.4-2.sdl7.noarch.rpm
wget http://springdale.math.ias.edu/data/puias/unsupported/7/x86_64/python-dnf-0.6.4-2.sdl7.noarch.rpm
yum install python-dnf-0.6.4-2.sdl7.noarch.rpm dnf-0.6.4-2.sdl7.noarch.rpm dnf-conf-0.6.4-2.sdl7.noarch.rpm
@alexmorley
alexmorley / multi-arg-mapslices.jl
Last active Dec 13, 2017
Mapslices with more than one argument
View multi-arg-mapslices.jl
import Base.Slice
import Base._unsafe_getindex!
function mapslices2(f, A::AbstractArray, B::AbstractArray, dims::AbstractVector)
if isempty(dims)
return map(f,A,B)
end
@assert size(A) == size(B)
@alexmorley
alexmorley / switchPS1_size.sh
Last active Oct 31, 2017
Switch prompt depending on window width
View switchPS1_size.sh
## CHANGE PROMPT DEPENDING ON WINDOWSIZE ##
## ADD THIS AT THE END OF YOUR .BASHRC ##
PS1_short="\[\033[01;34m\]\W\[\033[00m\]\$ "
PS1_long="$PS1"
check_terminal_size () {
if [ $COLUMNS -le 100 ]; then
PS1=$PS1_short
elif [ $COLUMNS -gt 100 ]; then
View nestedtmux.conf
unbind C-b
set -g prefix C-a
# set active shell to green, other one to blue
set -g status-bg colour40
setw -g window-status-current-bg colour40
# Some other shortcuts that can be useful for some
# bind -n C-t new-window -a
# bind -n S-left prev
View mwahaha
echo "mwhahahahahahaah" | osd_cat -p middle -A center -f '-*-*-*-*-*-*-*-500-*-*-*-*-*-*'
View keybase.md

Keybase proof

I hereby claim:

  • I am alexmorley on github.
  • I am alexmorley (https://keybase.io/alexmorley) on keybase.
  • I have a public key ASCMXMkOIW8F0QleqN36czTAbhUjxj2QQ5rVXaVX3tTWxgo

To claim this, I am signing this object: