Skip to content

Instantly share code, notes, and snippets.

@polarblau
polarblau / gist:8f96785b82335dc6ee36f47e648de5a1
Last active September 17, 2023 19:48
Download IKEA shopping cart as CSV
var productList = document.querySelector(
'[data-testid="product_list_product_group_items"]'
);
var products = productList.querySelectorAll("[class^='product_product']");
const sizeRegex = /(\d+)x(\d+) cm/;
const delimiter = ";";
const headers = [
"Article Nr.",
"Name",
'use strict';
/** Base class for generic event handling.
* @example
*
* // Don’t forget to call `super()` if defining a constructor.
* class Foo extends Eventable {}
* let foo = new Foo();
*
* foo.on('bar', (data) => console.log(data));
@polarblau
polarblau / config.ru
Created June 19, 2013 20:01 — forked from adamesque/config.ru
Protect a Middleman application via basic auth
require 'rubygems'
require 'middleman/rack'
protected_middleman = Rack::Auth::Basic.new(Middleman.server) do |username, password|
[username, password] == ['theuser', 'thepassword']
end
run protected_middleman
@polarblau
polarblau / amzn_wish_list_transfer.rb
Last active March 17, 2021 13:16
Transferring Amazon wish list entries the hard way between international stores.
#!/usr/bin/env ruby
require "rubygems"
require "mechanize"
SOURCE_LOGIN_URL = "https://www.amazon.com/ap/signin?_encoding=UTF8&openid.assoc_handle=usflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fgp%2Fcss%2Fhomepage.html%3Fie%3DUTF8%26*Version*%3D1%26*entries*%3D0%26ref_%3Dnav_signin"
TARGET_LOGIN_URL = "https://www.amazon.de/ap/signin?_encoding=UTF8&openid.assoc_handle=deflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2F
@polarblau
polarblau / install_pg_gem.sh
Created April 26, 2020 14:34
Installing the pg gem when using the postgres.app
# No pg_config... trying anyway. If building fails, please try again with
# --with-pg-config=/path/to/pg_config
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/[YOUR postgres.app VERSION]/bin/pg_config
@polarblau
polarblau / utilities.rake
Created September 7, 2011 10:57
Find TODOs in your Rails project and create Github issues accordingly
require 'net/http'
require 'json'
# For the lazy like me who find themselves
# frequently adding lines like
# TODO: add documentation
#
# Find all these lines in the current project
# and create Github issues accordingly
# The issue will contain a link to the current branch
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
@polarblau
polarblau / work_days_2016.md
Created January 14, 2016 11:35
Work days / Berlin, Germany (2016)
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
Days: 20 21 21 21 20 22 21 23 22 20 22 21
Hours: 150 157,5 157,5 157,5 150 165 157,5 172,5 165 150 165 157,5

(Hours calculations are based on 7.5 hour days.)

2.0.0p0 :012 > stores = Store.limit(10)
Store Load (3.3ms) SELECT "stores".* FROM "stores" LIMIT 10
=> #<ActiveRecord::Relation [#<Store … SNIP … ]>
2.0.0p0 :013 > stores.class
=> ActiveRecord::Relation::ActiveRecord_Relation_Store
2.0.0p0 :014 > stores.size
=> 10
.reject!{|i| i.id.even?}
=> [#<Store … SNIP … >]
2.0.0p0 :016 > stores.size
/* >> First message */
/* >> Value of ghost-var: foo */