Skip to content

Instantly share code, notes, and snippets.

var resultList = document.querySelector('#s-results-list-atf');
var results = resultList.getElementsByTagName('li');
for (var i=0; i<results; i++) {
console.log(results[i].getAttribute('data-asin');
}
@embayer
embayer / notify.py
Created February 4, 2017 16:54
use applescript to display a notification on macOS
def notify(title, subtitle, notification, soundname='Hero'):
''' use applescript to display a notification on macOS
'''
osascript_params = {
'title': title,
'subtitle': subtitle,
'soundname': soundname,
'notification': notification
}
osascript_cmd = '\'display notification \"{notification}\" with title \"{title}\" subtitle \"{subtitle}\" sound name \"{soundname}\"\''.format(**osascript_params)
@embayer
embayer / progressbar.py
Last active February 4, 2017 16:57
render a progressbar on the commandline
def progressbar(seconds, prefix='', suffix=''):
''' render a progressbar on the commandline
'''
def print_progressbar(iteration, total, decimals=1, length=100, fill= '█'):
"""
Call in a loop to create terminal progress bar
@params:
iteration - Required : current iteration (Int)
total - Required : total iterations (Int)
@embayer
embayer / countdown.py
Created February 4, 2017 15:54
render a countdown on the commandline
def countdown(timeout):
''' render a countdown on the commandline
''' @param timeout: minutes to count down
while timeout:
mins, secs = divmod(timeout, 60)
cntdwn = '{:02d}:{:02d}'.format(mins, secs)
print(cntdwn, end='\r')
sleep(1)
timeout -= 1
@embayer
embayer / apps.org
Last active May 28, 2017 09:56
collection of cheat sheets

apps

slack

shortcuts

<cmd> / <ctrl> are equivalent

shortcutaction
@embayer
embayer / gen_tree.py
Created January 17, 2017 15:04
generate a category tree from a list of category strings
def gen_tree(self, category_strs):
''' takes an array of category strings eg:
["Heim & Garten > Rasen & Garten > Bewässerungssysteme",
"Heim & Garten > Rasen & Garten > Gartenbau"]
and returns an category tree dict eg:
{
"root": {
"children:": {
"Heim & Garten": {
"slug": {
@embayer
embayer / macos_cheatsheet.md
Last active October 29, 2016 16:23
macOS cheatsheet

Finder

<Cmd><Shift>G ................. open directory path

input

.............. open emoji keyboard

@embayer
embayer / sql_cheatsheet.sql
Last active June 21, 2016 11:08
sql cheatsheet
-- find duplicated values
SELECT
address_line1, address_line2, zip, city, country, COUNT(*)
FROM
location
GROUP BY
address_line1, address_line2, zip, city, country
HAVING
COUNT(*) > 1;
@embayer
embayer / emacs.md
Last active June 3, 2021 22:38
emacs cheatsheet

basic operations

help

<Ctrl-h> a ....................... get help for a command (word list or regexp)
<Ctrl-h> k ....................... describe key

save

................. save the current buffer

@embayer
embayer / make_list.make
Created May 12, 2016 08:31
make target that lists all visible targets in a Makefile
.PHONY: list
list:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs | tr ' ' '\n'