Skip to content

Instantly share code, notes, and snippets.

View bjesus's full-sized avatar

Yo'av Moshe bjesus

View GitHub Profile
@bjesus
bjesus / sync
Created August 27, 2014 10:13
Keep inputs with the same name in sync (jQuery)
$("input[name]").bind("keyup paste", function() {
elm = $(this);
elm_name = elm.attr('name');
$('input[name='+elm_name+']').val( elm.val() )
});
@bjesus
bjesus / account.rb
Created August 30, 2011 13:27
DocumentNotFound with nested attributes
class Account
include Mongoid::Document
field :name, :type => String
field :surname, :type => String
has_and_belongs_to_many :kenim_rakaz, :class_name => 'Ken', :inverse_of => :rakazim
end
@bjesus
bjesus / run-in-console.js
Created February 19, 2016 12:40
Read Haaretz with an ad blocker
CookieUtil.setCookie('HtzPusr', 'its-my-right-to-use-the-internet-as-i-want-to');
// This will make the website think you're a registered user.
// While allowing you to use an ad blocker, it should also
// allow to you "Zen Reading" mode etc'.
@bjesus
bjesus / index.html
Created September 28, 2016 11:21
Hebrew text with Arabic diacritics
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hebrew text with Arabic diacritics</title>
</head>
<body dir="rtl">
<h1>אֶלסָّלָאם אלשָّאמֶל ואלעָאדֶל ואלכָּאמֶל</h1>
==> Retrieving sources...
-> Found gitin-0.1.5.tar.gz
==> Validating source files with sha256sums...
gitin-0.1.5.tar.gz ... Passed
==> Removing existing $srcdir/ directory...
==> Extracting sources...
-> Extracting gitin-0.1.5.tar.gz with bsdtar
==> Sources are ready.
==> Making package: gitin 0.1.5-2 (Sun 03 Mar 2019 16:02:32 CET)
==> Checking runtime dependencies...
@bjesus
bjesus / apple-music-playlist-to-text.js
Created July 24, 2020 10:35
apple music playlist to text
// Run in the browser console
songlist = ""
for (const song of document.getElementsByClassName('two-lines')) {
title = song.getElementsByClassName('song-name')[0].textContent.trim()
artist = song.getElementsByClassName('by-line')[0].textContent.trim()
a += artist+" - "+title+"\n"
@bjesus
bjesus / config.json
Last active September 16, 2020 15:00
Catt (chromecast) indicator for Waybar
"custom/cast": {
"format": "{icon} {}",
"tooltip": true,
"interval": 3,
"return-type": "json",
"format-icons": {
"default": "🎜"
},
"exec": "/PATH/TO/waybar-catt.py",
"exec-if": "nmcli -t | grep -q NAME_OF_YOUR_HOME_WIFI",
@bjesus
bjesus / 0-not-your-lab.md
Last active June 10, 2022 20:40
My browser isn't your lab, do you tests elsewhere - turning off the Performance Web API

RUM testing is inherently flawed

Everyone wants their website to be fast. For many years, we had synthetic tests: you spin up some automated browser, load your site, measure, done. It's not perfect, but it's a pretty good indicator for how fast your website is. You can simulate slow networks. You can run this automated browser on a different continent. It offers some flexibility.

But then someone convinced us all that it isn’t enough. You have to actually measure the peformance in the browsers of your users. RUM came into the world. From MDN:

Real User Monitoring or RUM measures the performance of a page from real users' machines. Generally, a third party script injects a script on each page to measure and report back on page load data for every request made. This technique monitors an application's actual user interactions. In real user monitoring, the browsers of real users report back performanc

@bjesus
bjesus / config.json
Last active May 21, 2023 11:27
Khal indicator for Waybar
"custom/events": {
"format": "{}",
"tooltip": true,
"interval": 300,
"format-icons": {
"default": ""
},
"exec": "waybar-khal.py",
"return-type": "json"
},
@bjesus
bjesus / gvb.sh
Created October 25, 2023 09:15
GVB station departures
#!/bin/sh
echo '[5,"/stops/09900"]' | websocat wss://maps-wss.gvb.nl/ -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0' | tail -n +2 | while read -r line; do printf '%s\n' "$line" | jq -r '.[2]' | jq -r '.trip.lastCallMade.plannedDepartureAt + " " + .journey.publicLineNumber + " " + .journey.destination + " (" + .trip.lastCallMade.status + ", " + (.trip.lastCallMade.delay|tostring) + " delay)"'; done