Skip to content

Instantly share code, notes, and snippets.


jakub-g jakub-g

View GitHub Profile
jakub-g /
Last active Jun 30, 2020
Unicode-aware JavaScript regex cheat sheet

Unicode-aware JavaScript regex (Unicode property escapes /\p{..}\P{..}/u) cheat sheet

Browser support MDN

jakub-g / regex-u-test.js
Last active Apr 2, 2020
regex u flag test
View regex-u-test.js
console.log("Wikipedia Википедия Wikipedia Βικιπαίδεια Wikipedia".match(/\p{Letter}+/gu))
console.log("Wikipedia Википедия Wikipedia Βικιπαίδεια Wikipedia".match(/\b\p{Letter}+\b/gu))
jakub-g /
Last active Feb 25, 2020
go to root folder of git repo from a bash script
# first, switch to the directory of where the currently executing script is located
cd "$( dirname "${BASH_SOURCE[0]}" )"
# now, find the git repo root, and switch to that directory
cd "./"$(git rev-parse --show-cdup)
# now, run stuff from the git root
View ip.php
$remote = @$_SERVER['REMOTE_ADDR'];
printf("%s\n", (($name = gethostbyaddr($remote)) !== false) ? $name : $remote);
jakub-g / window proxy.html
Last active Oct 9, 2019
Proxying reads from global variables via ES6 proxy and `with`
View window proxy.html
<!doctype html>
<meta charset="utf-8">
var windowProxy = new Proxy(window, {
get: function(target, propKey, value) {
if (typeof propKey !== 'symbol') {
jakub-g / kibana scripted
Created Jun 25, 2019
kibana adhoc scripted field vs scripted field defined in panel
View kibana scripted

scripted field

if (!doc['data.request_response_time'].empty) {
  return doc['data.request_response_time'].value + doc['data.response_to_boot_start_time'].value + doc['data.boot_def_time'].value + doc['data.dmp_call_time'].value + doc['data.dmp_create_time'].value

return null
jakub-g /
Created May 6, 2019
mkcert for npm's http-server
mkcert -cert-file cert.pem -key-file key.pem "*"
jakub-g /
Last active Feb 6, 2020
navigator.sendBeacon brain dump -- many not so great points

navigator.sendBeacon(url, data)

The data parameter is an ArrayBufferView, Blob, DOMString, or FormData object containing the data to be transmitted.

  • no plain old key-value JS object :| serialization of an object to a string up to the developer

  • always POST, not possible to send GET :|

  • when DOMString passed, the request type is Content-Type: text/plain, hence expressjs middlewares that read postdata won't process it :/ need to write custom middleware

jakub-g /
Last active Apr 12, 2019
Installing old version of Firefox on Windows for testing and preventing it from self-updating
  1. Grab old version of Firefox from Mozilla's FTP. They downloads are placed in folders that follow a simple naming convention. For example v63.0 is here:

  1. Run the installer and install it to a folder like c:\software\firefox63

  2. IMPORTANT: turn off internet connectivity at system level before running Firefox for the first time! Otherwise it will automatically self-update! (Windows 10 has "airplane mode").

  3. Create a shortcut with special command line switches

jakub-g / gist:a826368ac9ec5f82d32f9e2d93ea3a0f
Created Mar 14, 2019
vscode prevent watcher to keep a lock
View gist:a826368ac9ec5f82d32f9e2d93ea3a0f
open .vscode/settings.json
You can’t perform that action at this time.