Skip to content

Instantly share code, notes, and snippets.

View elstanto's full-sized avatar
🚂
choo choo

Laurence Stant elstanto

🚂
choo choo
  • CERN
  • Switzerland
View GitHub Profile
import jmri
jmri.util.JmriJFrame.getFrame("PanelPro").setState(jmri.util.JmriJFrame.ICONIFIED)
import jmri
from java.awt import Toolkit
screensize = Toolkit.getDefaultToolkit().getScreenSize()
for frame in jmri.util.JmriJFrame.getFrameList():
if frame.title == "Analog Clock" and frame.isVisible():
frame.setExtendedState(frame.getExtendedState() | frame.MAXIMIZED_BOTH)
frame.getContentPane().getComponents()[0].setSize(screensize)
frame.getContentPane().getComponents()[0].scaleFace()
import ast
import re
def closing_brace_pos(string):
"""Finds the position of the extra closing bracing ending the eval block"""
count = 0
in_string = False
for i in range(0, string.__len__()):
if string[i] == "\"":
@elstanto
elstanto / gist:32e5f5c0b45548d3f9b1f4200086d774
Created January 13, 2017 16:44
Cool electronics projects
https://github.com/formatc1702/Micro-Word-Clock
@elstanto
elstanto / post-receive hook
Created March 5, 2014 13:08
A git post-receive hook for checking out a repo on a bare server to the working directory (see http://toroid.org/ams/git-website-howto) and also pushing to all further remotes.
#!/bin/bash
umask 002
echo "Attempting checkout on server..."
if git checkout -f ; then
echo "Success!"
else
echo "Failed!"
fi
echo "Attempting push to other remotes..."
@elstanto
elstanto / autorenew.py
Last active August 29, 2015 13:56
This code will renew all library books from Surrey University library. Either set it as a daily/weekly cron job or have it run from an email trigger when you receive the renew notification.
"""
Code to renew all books from Surrey Uni library. If there are any issues check that the url is correct and has not changed!
"""
#!/usr/bin/python
import mechanize as m
#This should be the My Account login page URL
url = "https://capitadiscovery.co.uk/surrey-ac/login?message=borrowerservices_notloggedin&referer=https%3A%2F%2Fcapitadiscovery.co.uk%2Fsurrey-ac%2Faccount"