Skip to content

Instantly share code, notes, and snippets.

@jasonrobot
jasonrobot / FancyWaiting.java
Last active August 22, 2018 19:08
Some examples of more complicated waits for tricky scenarios
/* for this one, we were entering text to a textarea element, and it was being stored as the element's value. Selenium
* is fast enough that it will do this, then move on the the next bit of code (usually clicking a save or done button)
* before JS has updated the value with the text. Its tempting to use a Thread.sleep, but using Selenium's built-in
* waits, we can handle this */
el(socialIconUrlInput).sendKeys(url);
wait.until(ExpectedConditions.textToBePresentInElementValue(socialIconUrlInput, url)); //now we're sure its ok to move on
clickElement(el(doneButton));
/* in this case, a button was being clicked that caused a list of options to change in the UI. These option buttons were
* being removed, then replaced with the new ones when the button was clicked (which gets done via JS). Selenium would
@jasonrobot
jasonrobot / delete-merged-branches.sh
Last active December 21, 2016 22:30
Cool git commands (some shell in there too). Alias these to stuff in your shell if you want to use them quickly.
#deletes all branches that have been merged into master (except your current branch) (substitute "master" for whatever branch you want to clean against)
git branch --merged master | grep -v "\*" | xargs -n 1 git branch -d
#you can leave off the last command to just list them
@jasonrobot
jasonrobot / assert.java
Last active February 16, 2017 21:19
The magic of assertions
if (3 != 3)
{
fail("equality check failed on 3");
}
/*
* That's fine, except that we're usually comparing dynamic data retrieved from the app.
* Sometimes we aren't even comparing against static data
*/
for (String result : results)
{
@jasonrobot
jasonrobot / touchpad.fish
Last active March 20, 2018 21:18
toggles the synaptics touchpad on and off, or you can specify on and off
#!/usr/bin/env fish
# Usage:
# run with no args to toggle between on and off
# pass a single arg "on" or "off" to do exactly what you'd expect
# drop it in ~/bin with a nice name (I have ~/bin/tp) or bind it to a hotkey or something like that
function turn-on
echo "turning on"
synclient touchpadoff=0
(defun beginning-of-line-or-indentation ()
"Move to beginning of line, or indentation."
(interactive)
(let ((start (point)))
(back-to-indentation)
;; now if point is the same as when we started, we're already at indent start
(if (= start (point))
(beginning-of-line))))
(global-set-key (kbd "C-a") 'beginning-of-line-or-indentation)
@jasonrobot
jasonrobot / volume.fish
Created April 24, 2018 15:51
Bind this to your media keys to control whatever pulse audio syncs are active.
#!/usr/bin/env fish
set -l current_sinks (pactl list short sinks | grep -i "running" | awk "{ print \$1 }")
for sink in $current_sinks
switch $argv[1]
case mute unmute
echo "toggling mute"
pactl set-sink-mute $sink toggle
case up
@jasonrobot
jasonrobot / sequence-functions.lisp
Last active December 28, 2018 07:06
Common lisp, why no have common sequence functions!?! >:-|
(defun all (seq fn)
"Immediately return NIL if FN returns NIL for any item in SEQ."
(loop for i in seq
always (funcall fn i)))
(all '(1 2 3) (lambda (x) (< x 5)))
;; => T
(all '(1 2) (lambda (x) (= x 1)))
;; => NIL
<project name="MyProject" default="dist" basedir=".">
<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<target name="init">
@jasonrobot
jasonrobot / timer.lisp
Created May 8, 2018 22:58
Simple command line invoked timer. I plan to add some way of notifying.
#!/usr/bin/sbcl --script
;;; Documentation:
;;; Commentary:
;;; Code:
(defun timer-tick ()
"Waits for 1 second"
@jasonrobot
jasonrobot / test-ng-deps.java
Created May 15, 2018 23:45
Z runs, Y runs and fails, X skips, W goes anyways, but after Y.
public class TestTestDeps
{
@Test(alwaysRun = true)
public void testZ()
{
System.out.println("z is running");
assertEquals(1, 1);
}
@Test(dependsOnMethods = "testZ")