Skip to content

Instantly share code, notes, and snippets.

@nsauk
nsauk / puts_hist.rb
Last active February 16, 2023 23:24 — forked from nevans/gist:9374041
simple ruby console histogram generator
# Pass in an enumeration of data and
# (optionally) a block to extract the grouping aspect of the data.
#
# Optional: sort_by lambda (operates on group key and count)
def puts_hist(data, sort_by: nil, &block)
data = data.map(&block) if block
counts = data.each_with_object(Hash.new(0)) { |k, h| h[k] += 1 }
max = counts.values.max
width = ENV['COLUMNS'].to_i
@nsauk
nsauk / glovo-address-remover.js
Created November 20, 2020 13:25
Remove saved delivery address from Glovo (bookmarklet, client-side)
javascript:
addresses = JSON.parse(localStorage.glv_user_addresses);
for (var i in addresses) {
address = addresses[i];
if (confirm(address.fullText + "\n\n" + $nuxt.$i18n.t('common.remove') + "?")) {
delete addresses['DELIVERY.' + address.placeId]
};
};
localStorage.glv_user_addresses = JSON.stringify(addresses);
location.reload();