Skip to content

Instantly share code, notes, and snippets.

View alexmorley's full-sized avatar
🏠
Working from home

Alexander Morley alexmorley

🏠
Working from home
View GitHub Profile
@alexmorley
alexmorley / install_dnf_c7.sh
Created January 5, 2018 11:25
dnf on centos 7
## 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 / rge
Created July 21, 2020 17:30
Ripgrep then search / edit
#!/bin/sh
exec vim +/"${@: -1}" -p $(rg -l "$@")
#!/bin/sh
exec vim +/"${@: -1}" -p $(rg -l "$@")
@alexmorley
alexmorley / triangle.py
Last active April 15, 2019 18:38
Python class to fill in missing angles and vertices of a triangle
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 March 28, 2019 12:37
Adding commits to a repo from another with unrelated commit histories
# 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'
@alexmorley
alexmorley / multi-arg-mapslices.jl
Last active December 13, 2017 16:08
Mapslices with more than one argument
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 October 31, 2017 16:18
Switch prompt depending on window width
## 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
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
echo "mwhahahahahahaah" | osd_cat -p middle -A center -f '-*-*-*-*-*-*-*-500-*-*-*-*-*-*'

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: