Skip to content

Instantly share code, notes, and snippets.

View encima's full-sized avatar
🐴
selling spare horse kidneys. PM me

Chris Gwilliams encima

🐴
selling spare horse kidneys. PM me
View GitHub Profile
@encima
encima / remove_history.sh
Last active September 14, 2020 19:45
Remove Git History|-|{"files":{"remove_history.sh":{"env":"plain"}},"tag":"Shell"}
#!/bin/sh
cd $1 #repo path
git fetch -p
for branch in `git for-each-ref --format='%(refname:short)' refs/remotes/origin`;
do
IFS='origin/' read -ra BRANCHNAME <<< "$branch"
name=`awk -F"origin/" '{print $2}' <<< $branch`
echo $name
if [ $name != 'HEAD' ]
@encima
encima / Ireland.kml
Last active September 14, 2020 19:46
BNC KML|-|{"files":{"Wales.kml":{"env":"plain"}},"tag":"Uncategorized"}
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>Ireland.kml</name>
<Style id="s_ylw-pushpin">
<IconStyle>
<scale>1.1</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
</Icon>
@encima
encima / clip.py
Last active August 23, 2017 13:16
Python clipboard manager/saver
import pyperclip
import sys
from ruamel.yaml import YAML
FILE = sys.argv[1]
data = []
def exists(clips, string):
found = False
print(string.lower())
@encima
encima / ascii_wizard.py
Last active September 14, 2020 19:46
Yer a gizzard Larry|-|{"files":{"wizard.py":{"env":"plain"},"ascii_wizard.py":{"env":"plain"}},"tag":"Python"}
#!/usr/bin/env python
"""wizard.py: Generate all the ways of telling someone they are a something"""
__author__ = "@shockham"
import pycorpora
import random
from pyfiglet import figlet_format
from termcolor import cprint
@encima
encima / docker.md
Last active May 2, 2017 08:59
docker_cheat_sheet

General and Maintenance

  • docker system prune - Removes all unused images, containers, volumes etc
  • docker container prune - Removes all stopped containers
  • docker ps -a - list all containers
  • docker images - list all images

Containers

  • docker attach -it - Attach to a running container
@encima
encima / inspect.sh
Last active March 27, 2017 08:22
Git Review Commands
#!/bin/sh
#Inspect current branch (requires local copy)
gitinspector --since=1.week.ago -F html -HTlrm > <OUTPUT.HTML>"
#show the diff between two (can do more) branches in a single file
git diff <BRANCH_ONE> -- app/src/main <BRANCH_TWO> -- app/src/main > CHANGES.diff;
#output of commits with no gitinspector requirement
git log --pretty=format:"%ad:%an:%d:%B" --date=short --reverse --all --since=2.months.ago --author=<USERNAME>
@encima
encima / smtp_test.py
Last active September 14, 2020 19:48
Test script for HTML emails in SMTPlib|-|{"files":{"smtp_test.py":{"env":"plain"}},"tag":"Python"}
import smtplib
import sys
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from_email = "FROM_EMAIL_HERE"
from_pwd = "PWD_HERE"
to_email = "TO_EMAIL_HERE"
# Set up base of image
@encima
encima / assignment_unpack.py
Created November 15, 2016 09:53
Unpack Student Projects from a Teaching Solution to Sub Folders for Each Student
import os
import sys
import time
import shutil
import subprocess
# ENSURE YOUR FEEDBACK FILE IS IN THE PATH SUPPLIED
path = sys.argv[1] #full path should go here
module_code = sys.argv[2]
@encima
encima / install.sh
Last active September 14, 2020 19:48
A script to install all things needed for Jupyter notebooks in my teaching|-|{"files":{"requirements.txt":{"env":"plain"},"install.sh":{"env":"plain"}},"tag":"Python"}
#!/bin/bash
virtualenv tenv
source tenv/bin/activate
sudo pip install rise
jupyter nbextension enable rise --py --sys-prefix
pip install -r requirements.txt
pip install https://github.com/ipython-contrib/jupyter_contrib_nbextensions/tarball/master
@encima
encima / mds.r
Last active August 10, 2016 10:48
Multivariate Analysis and MDS Scratchpad
library(MASS)
library(car)
makeProfilePlot <- function(list,words) {
# find out the minimum and maximum values of the variables:
mymin <- 1e+20
mymax <- 1e-20
for (i in 1:length(list)) {
vectori <- mylist[[i]]
mini <- min(vectori)