Skip to content

Instantly share code, notes, and snippets.

@awls99
awls99 / gist:8440770
Created January 15, 2014 17:41
Notes on having more then one browser supported in cucumber at the same time.
########## CUCUMBER SAMPLE ###########
Given user "jon" goes to "google.com"
#turns into:
Given /^user "([^"]*)" goes to "([^"]*)"/ do |user_key, url|
@users[user_key].browse do |browser|
browser.goto url
end
end
######## HOOKS SAMPLE ###############
require 'thwait'
Then /^all links are valid$/ do
errors = []
threads = []
@links.each do |link|
threads << Thread.new do
last_response = get link.url
errors.push "#{link.url} LINK IS BROKEN" unless last_response.success?
end
@awls99
awls99 / errorclasses
Created January 29, 2015 11:21
Error classes for lazy bums like myself example
#The following two examples are equivalent
#Example 1, explicit error classe declaration
class MyMainNamespace
module Errors
class Error1 < StandardError; end
class Error2 < StandardError; end
end
end
@awls99
awls99 / random_correctness.rb
Last active July 21, 2017 13:23
Some math 4 4's thinggy
math_methods = Math.methods(false).each do |m|
self.class.send(:define_method, m, Proc.new do |x| Math.method(m).(x); end )
end
math_methods.delete_if{|m| %I[atan2 hypot acos asin atan atanh frexp lgamma ldexp].include? m}
def sqrt x
Math.sqrt x
end
ops = [' + 4.0 ', ' - 4.0 ', ' * 4.0', ' / 4.0 ',]
mixer = %w[* - + /]
@awls99
awls99 / wallpaperShuffle.sh
Last active July 28, 2024 22:44
Ubuntu random wallpaper
#!/bin/sh
# */5 * * * * /bin/sh /home/arthur/wallpaperShuffle.sh > /tmp/cronjob.log 2>&1
REAL_UID=$(id --real --user)
PID=$(pgrep --euid $REAL_UID gnome-session | head -n 1)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2- | sed -e "s/\x0//g")
PIC=$(ls /media/arthur/Fast\ Stuff/Cloudbox/Ultrawide\ wallpapers/* | shuf -n1 )
echo $PIC > /home/arthur/log