Skip to content

Instantly share code, notes, and snippets.

Avatar

jakub-g jakub-g

View GitHub Profile
@jakub-g
jakub-g / 1-unicode-js-regex.md
Last active Jun 30, 2020
Unicode-aware JavaScript regex cheat sheet
View 1-unicode-js-regex.md

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

Browser support MDN

@jakub-g
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
jakub-g / cd-to-git-root.sh
Last active Feb 25, 2020
go to root folder of git repo from a bash script
View cd-to-git-root.sh
#!/bin/bash
# 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
./somefolder/do-stuff.sh
View ip.php
<?php
$remote = @$_SERVER['REMOTE_ADDR'];
printf("%s\n", (($name = gethostbyaddr($remote)) !== false) ? $name : $remote);
@jakub-g
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>
<html>
<head>
<meta charset="utf-8">
<script>
var windowProxy = new Proxy(window, {
get: function(target, propKey, value) {
if (typeof propKey !== 'symbol') {
debugger
@jakub-g
jakub-g / kibana scripted fields.md
Created Jun 25, 2019
kibana adhoc scripted field vs scripted field defined in panel
View kibana scripted fields.md

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
jakub-g / mkcert.sh
Created May 6, 2019
mkcert for npm's http-server
View mkcert.sh
mkcert -cert-file cert.pem -key-file key.pem "*.example.com"
@jakub-g
jakub-g / sendBeacon.md
Last active Feb 6, 2020
navigator.sendBeacon brain dump -- many not so great points
View sendBeacon.md

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
jakub-g / installing-old-firefox.md
Last active Apr 12, 2019
Installing old version of Firefox on Windows for testing and preventing it from self-updating
View installing-old-firefox.md
  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:

https://ftp.mozilla.org/pub/firefox/releases/63.0/win64/en-US/

  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
jakub-g / gist:a826368ac9ec5f82d32f9e2d93ea3a0f
Created Mar 14, 2019
vscode prevent watcher to keep a lock
View gist:a826368ac9ec5f82d32f9e2d93ea3a0f
open .vscode/settings.json
files.exclude
files.watcherExclude
search.exclude
https://code.visualstudio.com/docs/getstarted/settings
You can’t perform that action at this time.