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 / github_makerepo.py
Last active September 14, 2020 19:50
Using the PyGithub library to create a new repo and initiate it in the current director.|-|{"files":{"github_makerepo.py":{"env":"plain"}},"tag":"Python"}
from github import Github
import sys, os
if len(sys.argv) == 4:
g = Github(sys.argv[1], sys.argv[2])
g.get_user().create_repo(sys.argv[3])
print '' + sys.argv[3] + ' created!'
print os.getcwd()
os.system('git init')
@encima
encima / resize.py
Last active September 14, 2020 19:49
Resizes a set of images found in a directory|-|{"files":{"resize.py":{"env":"plain"}},"tag":"Python"}
# Author: Chris Gwilliams
# Date: 22/7/14
# Usage: python resize.py [dir]
# Requires: PIL
# Purpose grabs every image in specified dir (and subdirs) and resizes according to the size variable
import os, sys
import Image
# set your size here, PIL will try and make it a bit smarter
size = 1280, 720
@encima
encima / OPENNI_RPI.sh
Last active December 1, 2016 19:52
OPENNI for RPI
sudo apt-get install openjdk-6-jdk libusb-1.0-0-dev
cd ~
mkdir OPENNI
cd OPENNI
mkdir OPENNI_RPI
cd OPENNI_RPI
if [ -f "OPENNI_RPI_SRC.zip"]
then
unzip OPENNI_RPI_SRC.zip
@encima
encima / find_n_move.sh
Last active September 14, 2020 19:50
Find files based on modified time and move to a directory|-|{"files":{"find_n_move.sh":{"env":"plain"}},"tag":"Shell"}
#!/bin/bash
# 1- file 2- minutes 3- dir
find $1 -mmin $2 -exec mv -t $3 {} \+
@encima
encima / pomo.sh
Last active September 14, 2020 19:49
A basic script to run pomodoro sessions in the terminal. Uses figlet, everything else comes with OS X|-|{"files":{"pomo.sh":{"env":"plain"}},"tag":"Shell"}
#!/bin/bash
# A simple script (for OS X, currently) that runs a pomodoro type session for the specified duration
c=1
while [ $c ]
do
if [ "$#" -ne 2 ]; then
echo "Usage: $0 DURATION BREAK_LENGTH" >&2
echo "Hint: 20 mins is 1200 seconds and 3 minutes is 180 seconds"
exit 1
@encima
encima / git_cheatsheet.md
Last active December 1, 2016 19:52
Git cheatsheet

Git Cheatsheet

GOLDEN RULE: PULL BEFORE YOU PUSH!

Initial Steps

  1. git init
    • Creates a git repository locally on your machine. (this is basically a .git folder with config and other things inside)
  2. git remote add origin <link>
    • Addss the link of the remote repository (github, gitlab) etc as the origin alias
@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)
@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 / 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 / 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