Skip to content

Instantly share code, notes, and snippets.

@Tattoo
Tattoo / differ.py
Created October 27, 2022 09:49
Script to parse changed Robot Framework tests from git diff
View differ.py
'''
$ git diff --unified=0 path/to/robot | python differ.py
'''
import re
import sys
from collections import defaultdict
from pathlib import Path
from robot.api import SuiteVisitor, TestSuiteBuilder
@Tattoo
Tattoo / post_to_slack.py
Last active June 14, 2022 13:22
Simple example script to send a message to Slack in Python
View post_to_slack.py
'''Simple example script below is quite straightforward.
Although Slack recommends integrating to it by writing Apps[1],
the old-school webhook integration still works as well
[1] https://api.slack.com/start/overview
'''
import json
import os
@Tattoo
Tattoo / gist:ba96380bf19b60e35049e70bb87267ef
Created October 14, 2021 07:59
Expand all in VersionOne
View gist:ba96380bf19b60e35049e70bb87267ef
// Add this as a bookmark in the bookmark bar
javascript:function expand(){ var els = $('a.show'); els.map((_, el) => el.click()); if (els.length > 0){ setTimeout(expand, 1500); } }; setTimeout(expand, 0)
@Tattoo
Tattoo / MabotLibrary.py
Last active April 7, 2020 13:49
Small dynamic library to facilitate running manual Robot Framework tests
View MabotLibrary.py
from itertools import chain
from robot.api import TestData
from robot.libraries.BuiltIn import BuiltIn
from robot.libraries import Dialogs
class MabotLibrary(object):
'''MabotLibrary facilitates running manual testing with Robot Framework.
@Tattoo
Tattoo / programmatic_rf.py
Created February 18, 2020 20:06
Programmatically create a Robot Framework test suite, then programmatically create a version we can save on disk
View programmatic_rf.py
# Example from https://robot-framework.readthedocs.io/en/latest/autodoc/robot.running.html#examples
from robot.api import TestSuite
suite = TestSuite('Activate Skynet')
suite.resource.imports.library('OperatingSystem')
test = suite.tests.create('Should Activate Skynet')
test.keywords.create('Set Environment Variable', args=['SKYNET', 'activated'])
test.keywords.create('Environment Variable Should Be Set', args=['SKYNET'])
result = suite.run(output='skynet.xml')
@Tattoo
Tattoo / fakedata.py
Created April 11, 2019 13:51
Some fake data generation in Python 3
View fakedata.py
from decimal import Decimal
from pprint import pprint
from random import choice, choices, randint
def random_digits(n):
"""Returns int with length `n`"""
start = 10**(n-1)
end = (10**n)-1
return randint(start, end)
@Tattoo
Tattoo / bedtime.sh
Created March 21, 2019 23:35
Easy sleep timer for OS X
View bedtime.sh
sleep 5400 && osascript -e 'tell application "Spotify" to pause'
# 5400 seconds == 90 minutes
@Tattoo
Tattoo / wrap_rf_variables.sublime-snippet
Created November 27, 2018 09:42
Wrap selected text with '${}' around it in Sublime
View wrap_rf_variables.sublime-snippet
<snippet>
<content><![CDATA[\${${SELECTION}}]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>hello</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<!-- keymap:
{ "keys": ["ctrl+r"], "command": "insert_snippet", "args":{"name": "Packages/User/wrap_rf_variables.sublime-snippet"}}
@Tattoo
Tattoo / self-validating.sql
Created November 1, 2018 15:10
Self-validating SQL queries for interactive
View self-validating.sql
-- https://stackoverflow.com/a/754570
SELECT CONCAT(
'Sufficient and sufficiently varied month_value test data: ',
CASE WHEN (
SELECT COUNT(DISTINCT y, m) FROM month_value
) > 10
AND (
SELECT COUNT(DISTINCT y) FROM month_value
) > 3
@Tattoo
Tattoo / script.sh
Last active November 27, 2018 09:33
Bash: Disabling output of "set -x" for one command
View script.sh
### 'set -x' is wonderful if you want to see the command as well as output in a script
function example {
echo "${1}"
}
VAR="foo"
set -x
example "${VAR}"
# + example foo