Skip to content

Instantly share code, notes, and snippets.

View dueyfinster's full-sized avatar

Neil Grogan dueyfinster

View GitHub Profile
@dueyfinster
dueyfinster / DFTwittterBot.java
Created April 23, 2012 09:29
Very Simple Java Twitter Bot (using Twitter4J)
package test;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
@dueyfinster
dueyfinster / percentage.sh
Created April 23, 2012 09:33
Script to output last 30% of file by lines
# !/bin/sh
# Public Domain, by Neil Grogan 2010
# Script to output last 30% of file by lines
OLDFILE="oldlog.txt"
NEWFILE="newlog.txt"
PERCENT=0.7
#Use wc to count lines
LINES=$(wc -l $OLDFILE | awk '{ print $1}')
@dueyfinster
dueyfinster / gist:5249878
Created March 26, 2013 22:24
Paramiko working code
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('testhost', username='test', key_filename='/home/test/.ssh/id_rsa')
stdin, stdout, stderr = ssh.exec_command('ls')
print stdout.readlines()
print stderr.readlines()
@dueyfinster
dueyfinster / gist:5822509
Created June 20, 2013 13:10
SSH Pattern Matching
host s*
HostName atrcu%h.example.com
User example1
Port 22
host b*
HostName atrcx%h.example.com
User example2
Port 22
host ??*
HostName atvts%h.example.com
# Class: eclipse
#
# This class installs eclipse and some useful components
#
# Parameters:
# - method: the method by which to get the package. if not to "wget" it will be the "ensure" value for downloading the package from services such as apt (Default: wget)
# - downloadurl: where to download the package from (Default: http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops4/R-4.2-201206081400/eclipse-SDK-4.2-linux-gtk-x86_64.tar.gz&url=http://eclipse.mirrorcatalogs.com/eclipse/downloads/drops4/R-4.2-201206081400/eclipse-SDK-4.2-linux-gtk-x86_64.tar.gz&mirror_id=1119)
# - downloadfile: the file the wget makes (Default: 'eclipse-SDK-4.2-linux-gtk-x86_64.tar')
# - pluginrepositories: repositories of plugins to search in (Default: ['http://download.eclipse.org/releases/juno/'])
# - pluginius: the ius to install (Default: [])
### Keybase proof
I hereby claim:
* I am dueyfinster on github.
* I am dueyfinster (https://keybase.io/dueyfinster) on keybase.
* I have a public key whose fingerprint is E4F8 2BC8 600C F5FC 3EF3 1B8C D30A F8AF 2D70 27B1
To claim this, I am signing this object:

Intro

TCL-Expect scripts are an amazingly easy way to script out laborious tasks in the shell when you need to be interactive with the console. Think of them as a "macro" or way to programmaticly step through a process you would run by hand. They are similar to shell scripts but utilize the .tcl extension and a different #! call.

Setup Your Script

The first step, similar to writing a bash script, is to tell the script what it's executing under. For expect we use the following:

#!/usr/bin/expect
@dueyfinster
dueyfinster / DeleteOlderNewslettersInGmail.js
Created May 13, 2016 13:39
Delete old newsletters in Gmail as soon as the the latest issue arrives, using Google Script
function processInbox() {
Logger.log("Starting");
var mailingLists = [
"list:'faa8eb4ef3a111cef92c4f3d4mc list <faa8eb4ef3a111cef92c4f3d4.583821.list-id.mcsv.net>'",
"list:'e2e180baf855ac797ef407fc7mc list <e2e180baf855ac797ef407fc7.654029.list-id.mcsv.net>'",
"list:'9f4b80a35728f7271fe3ea6ffmc list <9f4b80a35728f7271fe3ea6ff.511493.list-id.mcsv.net>'"
];
for(var i = 0; i < mailingLists.length; i++){
// process all threads in the Inbox
@dueyfinster
dueyfinster / nfsn.hugo.sh
Last active November 7, 2016 14:40
Builds hugo static website on NearlyFreeSpeech.NET
#!/bin/bash
# A Script to do a hugo build if any future posts exist
#set -x
cd $HOME/repos/ngrogan.com
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse origin)
if [ $LOCAL = $REMOTE ]; then
@dueyfinster
dueyfinster / sync_hpc_ucd.sh
Created November 29, 2016 12:33
Sync UCD VM
#!/bin/bash
rsync -urv --progress ~/Dropbox/dev/ucd/HPC/Assignments/ csserver.ucd.ie:/home/msc2013/ngrogan/Assignments/
sleep 1
rsync -urv --progress csserver.ucd.ie:/home/msc2013/ngrogan/Assignments/ ~/Dropbox/dev/ucd/HPC/Assignments/