Table of Contents

Helpful Scripts

Are we preparing for this future? I look around, and see a generation of bright, inventive designers wasting their lives shoehorning obsolete interaction models onto crippled, impotent platforms. I see a generation of engineers wasting their lives mastering the carelessly-designed nuances of these dead-end platforms, and carelessly adding more. I see a generation of users wasting their lives pointing, clicking, dragging, typing, as gigahertz processors spin idly and gigabyte memories remember nothing. I see machines, machines, machines.

Bret Victor in Magic Ink

software should not be so lazy; it should stop making the user do work that the computer is better suited to doing (e.g. remembering where they put files), and it should stop making users go through the same steps over and over again, as if it were the first time they had ever met this user.–A review of The Inmates are Running the Asylum

More ideas in The Inmates are Running the Asylum, About Face, and The_Humane_Interface

Today I was forced to edit a Microsoft Word document, containing comments (made by me, and by others) and tracked changes. I found myself wanting to delete all comments, and accept all tracked changes. It took a few minutes to figure out, and I very quickly gave up trying to actually discover the functionality within Word’s actual UI and resorted to using Google. God help me if I wanted to, say, delete only comments made by me within the last ten days.

Automatic Script Suggestion

Point p = b.GetClickablePoint();
 
// Move the mouse to the point. Then click
Mouse.MoveTo(p);
Mouse.Click();

Algorithm

The problem is to discover what is a repeated thing, with insertions of irrelevant things. (no deletions or reorderings I think…)

For now, make a hash table that, given each event (mouse click, keyboard sequence (to prevent taking too much time), screen refresh with new data??, etc.), stores the offset in the log that it exists. Then do a “find common sequence” run on each of the instances of that event and see if they match.

UI Automation Tools

UIAutomation

Doesn't support right click out of the box? LabelControl, like Vimium mouseless browsing for the whole Windows OS! Upgrade with UI Automation / AutoIt? (seems overkill but works well enough)

Use Cases

Need to enable “accessibility mode” in Chrome:chrome://accessibility/

List_of_GUI_testing_tools Ranorex is a nice tool too! Squish is rather expensive…

Ubuntu HUD in Windows

Ubuntu Automation

Success in Python! here (accesses Windows COM for UIAutomation, then you can call commands interactively on it!). Another is here

MAKE A SEPARATE THREAD (that doesn't get in way of user)

Installing Accerciser (Inspect for Ubuntu)

git clone git://git.gnome.org/accerciser
cd accerciser
sudo apt-get install libgtk-3-dev python-gobject-dev libatspi2.0-dev intltool
autoreconf -fi #They're using autoconf, which this command is the proper command
./configure
make

Great article by UI interaction designer that worked at Apple.

Smart Code Suggestion

Not always do I remember the name of a function? Why not search the docs for the functions too?

Gmail Keyboard Shortcuts

No collapse all keyboard shortcut??!?!?! ARGH

Web Automation

Selenium seems a great option, but only runs once after page load. Best to go with WebDriver (also included) which is a direct talker to the browser and allows waiting for AJAX stuff.

Regular Expressions

Unless performance is of utmost concern, it's often easier just to run your results through a second pass, skipping those that match the words you want to negate.

Regular expressions usually mean you're doing scripting or some sort of low-performance task anyway, so find a solution that is easy to read, easy to understand and easy to maintain. –Bryan Oakley

Also known as regex. Great tester at Regex101 Sticking with Python for now.

^ - match start of line
$ - match end of line
() - group 
? - something previous is optional
Description Code
Match except certain chars (* in this example) [^*]
Match except certain words (foo) ??
Stuff nearby stuff foo[\w\W]{1,1000}PMEMDev

Finding Stuff

Grepwin doesn't support searching the results again m(

Going with DocFetcher for now.

Lucene/DocFetcher Search Tips

“foo bar”~20 foo and bar within 20 words of each other

Unix

Keyboard completion from history. <Ctrl+R> then up arrow works out of the box. But just up arrow is solved with https://askubuntu.com/a/59855

grep -rn "string" . > search.txt      # Search for "string" in all files down from current directory
bash --login                          # Refresh terminal (reload .bashrc)
foo <Ctrl+R>                          # Search history for "foo" and display results??! //unverified//

Windows

Batch File

@ECHO off 
 
::Delete all stats files
 del %CD%\*.stats
 
for %%s in ("unit_test","integration_test") do (
	echo %%~s
 
	for %%X in (%%~s\*.mf) do ( 
 
		java simulator/framework/Elevator -head head.txt -cf %%~s/%%~nX.cf -mf %%~s/%%~nX.mf
		echo %%~nX
		:: Hold for a few seconds
		PING google.com -n 2 -w 60 > NUL
	)
 
	move /Y *.stats %%~s/
 
)

Terminal

//Windows
C:\> mklink /D C:\TestFolderLink C:\Users\Geek\TestFolder
symbolic link created for C:\TestFolderLink <<===>> C:\Users\Geek\TestFolder
//Unix
ln -s <thing you are pointing to> <pointer name>
ln -s /usr/var/foo/bar /home/nhergert/ptr
//Creates a backup of only the subfolder and waits 20 seconds. Also follows links?
wget -mk -w 20 -np http://example.com/subfolder/
Example:
//Create a 15KB/s limited pipe
sudo ipfw pipe 1 config bw 15KByte/s
//Attach the pipe to port 80
sudo ipfw add 1 pipe 1 src-port 80
//Remove the pipe (gotta remember this one!)
sudo ipfw delete 1
scp      <src>                         <dest>
scp filename.ext nolanher@nolanhergert.com:~/public_html/share/ 
mogrify -quality 100 -format jpg *.pgm //Batch convert all pgm files to jpg with quality of 100% and preserve filenames
scp *.jpg nolanher@nolanhergert.com:~/public_html/dokuwiki/data/media/robotics  //Upload to web server
unix> ssh username@serveraddress.edu -X
unix> Connecting...ssh details...You're in!
unix> synaptic / matlab / browser / etc.

ssh-keygen -t dsa
#Hit return for everything
scp ~/.ssh/id_dsa.pub nolanher@nolanhergert.com:.ssh/temp
ssh nolanher@nolanhergert.com  #Log into web server
cat .ssh/temp >> .ssh/authorized_keys  #Appends to authorized_keys in case you have multiple logins

AutoIT

Window interaction in Windows. Allows you to find pixel colors too. Function listing http://www.autoitscript.com/site/

AutoHotKey

;Copy some OS X keyboard functionality
 
!Left::Send  {Home}
!Right::Send {End}
!+Left::Send {LShift down}{Home}
!+Right::Send {LShift down}{End}
!Up:: Send   {PgUp}
!Down::Send  {PgDn}

Makefiles

Makefile
CC = gcc
 
#Compiler flags
CFLAGS = -g -Wall -std=c99
 
#Linker flags
LDFLAGS = 
 
#Should be same name as executable on bottom
#but...might not be necessary
all: proxy
 
csapp.o: csapp.c csapp.h
	$(CC) $(CFLAGS) -c csapp.c
 
proxy.o: proxy.c csapp.h
	$(CC) $(CFLAGS) -c proxy.c
 
#This needs to have the same name as one of your input files?!
proxy: proxy.o csapp.o
 
#Creates a gzip file of sources only
submit:
	(make clean; cd ..; tar czvf proxylab.tar.gz proxylab-handout)
 
clean:
	rm -f *~ *.o proxy

Number Manipulation

int pos = map(dist, 0, 1023, 0, 180);
int map(int x, int in_min, int in_max, int out_min, int out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}