Skip to content

Instantly share code, notes, and snippets.

View stamat's full-sized avatar
๐Ÿ’ฅ

Nikola Stamatoviฤ‡ stamat

๐Ÿ’ฅ
View GitHub Profile
@stamat
stamat / user-agents.json
Last active July 25, 2023 10:50
Numerous navigator.userAgent strings for RegEx testing, scraped from https://deviceatlas.com/blog/list-of-user-agent-string
{
"Android with Client Hints Mobile":"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36",
"Android with Client Hints":"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
"Android with Client Hints Mobile GZIP":"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36,gzip(gfe)",
"Samsung Galaxy S22 5G":"Mozilla/5.0 (Linux; Android 13; SM-S901U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Mobile Safari/537.36",
"Samsung Galaxy S22 Ultra 5G":"Mozilla/5.0 (Linux; Android 13; SM-S908U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36",
"Samsung Galaxy S21 5G":"Mozilla/5.0 (Linux; Android 13; SM-G991U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Mobile Safari/537.36",
"Samsung Galaxy S21 Ultra 5G":"Mozilla/5.0 (Linux; Android 13; SM-G998U) AppleWebKit/537.36 (KHTML, like Gecko) C
@stamat
stamat / imagebatch.rb
Created September 12, 2022 14:41
Ruby script for batch image resize and optimisation
#!/usr/bin/env ruby
# frozen_string_literal: true
# brew install imagemagick advancecomp gifsicle jhead jpegoptim jpeg optipng pngcrush pngquant jonof/kenutils/pngout
# gem install mini_magick image_optim image_optim_pack
# Usage: ./imagebatch.rb [src_dir] [dest_dir] [resize="200x200"] [format="jpg"]
require "mini_magick"
require "image_optim"
@stamat
stamat / package.json
Created March 10, 2022 19:47
rollup nunjucks scss watch livereload
{
"name": "el-camino-rapido",
"version": "1.0.0",
"author": "Nikola Stamatovic <@stamat>",
"homepage": "",
"private": true,
"dependencies": {
"inobounce": "^0.2.0",
"jquery": "^3.5.1",
"remove-focus-outline": "^1.2.1",
@stamat
stamat / wp_menu_tree.php
Last active June 16, 2024 11:42
WordPress submenu tree generator from a list of menu items ๐Ÿคฏ
// usage `get_menu_tree('your_menu');`
// PHP 5,7 and 8
function get_menu($menu_name) {
if (( $locations = get_nav_menu_locations()) && isset( $locations[$menu_name])) {
return wp_get_nav_menu_items($locations[$menu_name]);
}
return null;
}
@stamat
stamat / cubic-bezier.scss
Created May 29, 2021 20:27
Cubic Bezier in SCSS... Anyone? I have no idea where I was going with it...
@function cubic-bezier($t,$x1,$y1,$x2,$y2) {
$diff: 1 - $t;
$x: $diff * ( $diff * ($t * $x1) + $t * ($diff * $x1 + $t * $x2)) + $t * ($diff * ( $diff * $x1 + $t * $x2) + $t * ($diff * $x2 + $t));
$y: $diff * ( $diff * ($t * $y1) + $t * ($diff * $y1 + $t * $y2)) + $t * ($diff * ( $diff * $y1 + $t * $y2) + $t * ($diff * $y2 + $t));
@return ($x, $y);
}
@stamat
stamat / country_flag_emojis.txt
Created May 28, 2021 12:15
All country flag emojis separated by a vertical bar for RegExp usage
๐Ÿ‡ฆ๐Ÿ‡จ|๐Ÿ‡ฆ๐Ÿ‡ฉ|๐Ÿ‡ฆ๐Ÿ‡ช|๐Ÿ‡ฆ๐Ÿ‡ซ|๐Ÿ‡ฆ๐Ÿ‡ฌ|๐Ÿ‡ฆ๐Ÿ‡ฎ|๐Ÿ‡ฆ๐Ÿ‡ฑ|๐Ÿ‡ฆ๐Ÿ‡ฒ|๐Ÿ‡ฆ๐Ÿ‡ด|๐Ÿ‡ฆ๐Ÿ‡ถ|๐Ÿ‡ฆ๐Ÿ‡ท|๐Ÿ‡ฆ๐Ÿ‡ธ|๐Ÿ‡ฆ๐Ÿ‡น|๐Ÿ‡ฆ๐Ÿ‡บ|๐Ÿ‡ฆ๐Ÿ‡ผ|๐Ÿ‡ฆ๐Ÿ‡ฝ|๐Ÿ‡ฆ๐Ÿ‡ฟ|๐Ÿ‡ง๐Ÿ‡ฆ|๐Ÿ‡ง๐Ÿ‡ง|๐Ÿ‡ง๐Ÿ‡ฉ|๐Ÿ‡ง๐Ÿ‡ช|๐Ÿ‡ง๐Ÿ‡ซ|๐Ÿ‡ง๐Ÿ‡ฌ|๐Ÿ‡ง๐Ÿ‡ญ|๐Ÿ‡ง๐Ÿ‡ฎ|๐Ÿ‡ง๐Ÿ‡ฏ|๐Ÿ‡ง๐Ÿ‡ฑ|๐Ÿ‡ง๐Ÿ‡ฒ|๐Ÿ‡ง๐Ÿ‡ณ|๐Ÿ‡ง๐Ÿ‡ด|๐Ÿ‡ง๐Ÿ‡ถ|๐Ÿ‡ง๐Ÿ‡ท|๐Ÿ‡ง๐Ÿ‡ธ|๐Ÿ‡ง๐Ÿ‡น|๐Ÿ‡ง๐Ÿ‡ป|๐Ÿ‡ง๐Ÿ‡ผ|๐Ÿ‡ง๐Ÿ‡พ|๐Ÿ‡ง๐Ÿ‡ฟ|๐Ÿ‡จ๐Ÿ‡ฆ|๐Ÿ‡จ๐Ÿ‡จ|๐Ÿ‡จ๐Ÿ‡ฉ|๐Ÿ‡จ๐Ÿ‡ซ|๐Ÿ‡จ๐Ÿ‡ฌ|๐Ÿ‡จ๐Ÿ‡ญ|๐Ÿ‡จ๐Ÿ‡ฎ|๐Ÿ‡จ๐Ÿ‡ฐ|๐Ÿ‡จ๐Ÿ‡ฑ|๐Ÿ‡จ๐Ÿ‡ฒ|๐Ÿ‡จ๐Ÿ‡ณ|๐Ÿ‡จ๐Ÿ‡ด|๐Ÿ‡จ๐Ÿ‡ต|๐Ÿ‡จ๐Ÿ‡ท|๐Ÿ‡จ๐Ÿ‡บ|๐Ÿ‡จ๐Ÿ‡ป|๐Ÿ‡จ๐Ÿ‡ผ|๐Ÿ‡จ๐Ÿ‡ฝ|๐Ÿ‡จ๐Ÿ‡พ|๐Ÿ‡จ๐Ÿ‡ฟ|๐Ÿ‡ฉ๐Ÿ‡ช|๐Ÿ‡ฉ๐Ÿ‡ฌ|๐Ÿ‡ฉ๐Ÿ‡ฏ|๐Ÿ‡ฉ๐Ÿ‡ฐ|๐Ÿ‡ฉ๐Ÿ‡ฒ|๐Ÿ‡ฉ๐Ÿ‡ด|๐Ÿ‡ฉ๐Ÿ‡ฟ|๐Ÿ‡ช๐Ÿ‡ฆ|๐Ÿ‡ช๐Ÿ‡จ|๐Ÿ‡ช๐Ÿ‡ช|๐Ÿ‡ช๐Ÿ‡ฌ|๐Ÿ‡ช๐Ÿ‡ญ|๐Ÿ‡ช๐Ÿ‡ท|๐Ÿ‡ช๐Ÿ‡ธ|๐Ÿ‡ช๐Ÿ‡น|๐Ÿ‡ช๐Ÿ‡บ|๐Ÿ‡ซ๐Ÿ‡ฎ|๐Ÿ‡ซ๐Ÿ‡ฏ|๐Ÿ‡ซ๐Ÿ‡ฐ|๐Ÿ‡ซ๐Ÿ‡ฒ|๐Ÿ‡ซ๐Ÿ‡ด|๐Ÿ‡ซ๐Ÿ‡ท|๐Ÿ‡ฌ๐Ÿ‡ฆ|๐Ÿ‡ฌ๐Ÿ‡ง|๐Ÿ‡ฌ๐Ÿ‡ฉ|๐Ÿ‡ฌ๐Ÿ‡ช|๐Ÿ‡ฌ๐Ÿ‡ซ|๐Ÿ‡ฌ๐Ÿ‡ฌ|๐Ÿ‡ฌ๐Ÿ‡ญ|๐Ÿ‡ฌ๐Ÿ‡ฎ|๐Ÿ‡ฌ๐Ÿ‡ฑ|๐Ÿ‡ฌ๐Ÿ‡ฒ|๐Ÿ‡ฌ๐Ÿ‡ณ|๐Ÿ‡ฌ๐Ÿ‡ต|๐Ÿ‡ฌ๐Ÿ‡ถ|๐Ÿ‡ฌ๐Ÿ‡ท|๐Ÿ‡ฌ๐Ÿ‡ธ|๐Ÿ‡ฌ๐Ÿ‡น|๐Ÿ‡ฌ๐Ÿ‡บ|๐Ÿ‡ฌ๐Ÿ‡ผ|๐Ÿ‡ฌ๐Ÿ‡พ|๐Ÿ‡ญ๐Ÿ‡ฐ|๐Ÿ‡ญ๐Ÿ‡ฒ|๐Ÿ‡ญ๐Ÿ‡ณ|๐Ÿ‡ญ๐Ÿ‡ท|๐Ÿ‡ญ๐Ÿ‡น|๐Ÿ‡ญ๐Ÿ‡บ|๐Ÿ‡ฎ๐Ÿ‡จ|๐Ÿ‡ฎ๐Ÿ‡ฉ|๐Ÿ‡ฎ๐Ÿ‡ช|๐Ÿ‡ฎ๐Ÿ‡ฑ|๐Ÿ‡ฎ๐Ÿ‡ฒ|๐Ÿ‡ฎ๐Ÿ‡ณ|๐Ÿ‡ฎ๐Ÿ‡ด|๐Ÿ‡ฎ๐Ÿ‡ถ|๐Ÿ‡ฎ๐Ÿ‡ท|๐Ÿ‡ฎ๐Ÿ‡ธ|๐Ÿ‡ฎ๐Ÿ‡น|๐Ÿ‡ฏ๐Ÿ‡ช|๐Ÿ‡ฏ๐Ÿ‡ฒ|๐Ÿ‡ฏ๐Ÿ‡ด|๐Ÿ‡ฏ๐Ÿ‡ต|๐Ÿ‡ฐ๐Ÿ‡ช|๐Ÿ‡ฐ๐Ÿ‡ฌ|๐Ÿ‡ฐ๐Ÿ‡ญ|๐Ÿ‡ฐ๐Ÿ‡ฎ|๐Ÿ‡ฐ๐Ÿ‡ฒ|๐Ÿ‡ฐ๐Ÿ‡ณ|๐Ÿ‡ฐ๐Ÿ‡ต|๐Ÿ‡ฐ๐Ÿ‡ท|๐Ÿ‡ฐ๐Ÿ‡ผ|๐Ÿ‡ฐ๐Ÿ‡พ|๐Ÿ‡ฐ๐Ÿ‡ฟ|๐Ÿ‡ฑ๐Ÿ‡ฆ|๐Ÿ‡ฑ๐Ÿ‡ง|๐Ÿ‡ฑ๐Ÿ‡จ|๐Ÿ‡ฑ๐Ÿ‡ฎ|๐Ÿ‡ฑ๐Ÿ‡ฐ|๐Ÿ‡ฑ๐Ÿ‡ท|๐Ÿ‡ฑ๐Ÿ‡ธ|๐Ÿ‡ฑ๐Ÿ‡น|๐Ÿ‡ฑ๐Ÿ‡บ|๐Ÿ‡ฑ๐Ÿ‡ป|๐Ÿ‡ฑ๐Ÿ‡พ|๐Ÿ‡ฒ๐Ÿ‡ฆ|๐Ÿ‡ฒ๐Ÿ‡จ|๐Ÿ‡ฒ๐Ÿ‡ฉ|๐Ÿ‡ฒ๐Ÿ‡ช|๐Ÿ‡ฒ๐Ÿ‡ซ|๐Ÿ‡ฒ๐Ÿ‡ฌ|๐Ÿ‡ฒ๐Ÿ‡ญ|๐Ÿ‡ฒ๐Ÿ‡ฐ|๐Ÿ‡ฒ๐Ÿ‡ฑ|๐Ÿ‡ฒ๐Ÿ‡ฒ|๐Ÿ‡ฒ๐Ÿ‡ณ|๐Ÿ‡ฒ๐Ÿ‡ด|๐Ÿ‡ฒ๐Ÿ‡ต|๐Ÿ‡ฒ๐Ÿ‡ถ|๐Ÿ‡ฒ๐Ÿ‡ท|๐Ÿ‡ฒ๐Ÿ‡ธ|๐Ÿ‡ฒ๐Ÿ‡น|๐Ÿ‡ฒ๐Ÿ‡บ|๐Ÿ‡ฒ๐Ÿ‡ป|๐Ÿ‡ฒ๐Ÿ‡ผ|๐Ÿ‡ฒ๐Ÿ‡ฝ|๐Ÿ‡ฒ๐Ÿ‡พ|๐Ÿ‡ฒ๐Ÿ‡ฟ|๐Ÿ‡ณ๐Ÿ‡ฆ|๐Ÿ‡ณ๐Ÿ‡จ|๐Ÿ‡ณ๐Ÿ‡ช|๐Ÿ‡ณ๐Ÿ‡ซ|๐Ÿ‡ณ๐Ÿ‡ฌ|๐Ÿ‡ณ๐Ÿ‡ฎ|๐Ÿ‡ณ๐Ÿ‡ฑ|๐Ÿ‡ณ๐Ÿ‡ด|๐Ÿ‡ณ๐Ÿ‡ต|๐Ÿ‡ณ๐Ÿ‡ท|๐Ÿ‡ณ๐Ÿ‡บ|๐Ÿ‡ณ๐Ÿ‡ฟ|๐Ÿ‡ด๐Ÿ‡ฒ|๐Ÿ‡ต๐Ÿ‡ฆ|๐Ÿ‡ต๐Ÿ‡ช|๐Ÿ‡ต๐Ÿ‡ซ|๐Ÿ‡ต๐Ÿ‡ฌ|๐Ÿ‡ต๐Ÿ‡ญ|๐Ÿ‡ต๐Ÿ‡ฐ|๐Ÿ‡ต๐Ÿ‡ฑ|๐Ÿ‡ต๐Ÿ‡ฒ|๐Ÿ‡ต๐Ÿ‡ณ|๐Ÿ‡ต๐Ÿ‡ท|๐Ÿ‡ต๐Ÿ‡ธ|๐Ÿ‡ต๐Ÿ‡น|๐Ÿ‡ต๐Ÿ‡ผ|๐Ÿ‡ต๐Ÿ‡พ|๐Ÿ‡ถ๐Ÿ‡ฆ|๐Ÿ‡ท๐Ÿ‡ช|๐Ÿ‡ท๐Ÿ‡ด|๐Ÿ‡ท๐Ÿ‡ธ|๐Ÿ‡ท๐Ÿ‡บ|๐Ÿ‡ท๐Ÿ‡ผ|๐Ÿ‡ธ๐Ÿ‡ฆ|๐Ÿ‡ธ๐Ÿ‡ง|๐Ÿ‡ธ๐Ÿ‡จ|๐Ÿ‡ธ๐Ÿ‡ฉ|๐Ÿ‡ธ๐Ÿ‡ช|๐Ÿ‡ธ๐Ÿ‡ฌ|๐Ÿ‡ธ๐Ÿ‡ญ|๐Ÿ‡ธ๐Ÿ‡ฎ|๐Ÿ‡ธ๐Ÿ‡ฏ|๐Ÿ‡ธ๐Ÿ‡ฐ|๐Ÿ‡ธ๐Ÿ‡ฑ|๐Ÿ‡ธ๐Ÿ‡ฒ|๐Ÿ‡ธ๐Ÿ‡ณ|๐Ÿ‡ธ๐Ÿ‡ด|๐Ÿ‡ธ๐Ÿ‡ท|๐Ÿ‡ธ๐Ÿ‡ธ|๐Ÿ‡ธ๐Ÿ‡น|๐Ÿ‡ธ๐Ÿ‡ป|๐Ÿ‡ธ๐Ÿ‡ฝ|๐Ÿ‡ธ๐Ÿ‡พ|๐Ÿ‡ธ๐Ÿ‡ฟ|๐Ÿ‡น๐Ÿ‡ฆ|๐Ÿ‡น๐Ÿ‡จ|๐Ÿ‡น๐Ÿ‡ฉ|๐Ÿ‡น๐Ÿ‡ซ|๐Ÿ‡น๐Ÿ‡ฌ|๐Ÿ‡น๐Ÿ‡ญ|๐Ÿ‡น๐Ÿ‡ฏ|๐Ÿ‡น๐Ÿ‡ฐ|๐Ÿ‡น๐Ÿ‡ฑ|๐Ÿ‡น๐Ÿ‡ฒ|๐Ÿ‡น๐Ÿ‡ณ|๐Ÿ‡น๐Ÿ‡ด|๐Ÿ‡น๐Ÿ‡ท|๐Ÿ‡น๐Ÿ‡น|๐Ÿ‡น๐Ÿ‡ป|๐Ÿ‡น๐Ÿ‡ผ|๐Ÿ‡น๐Ÿ‡ฟ|๐Ÿ‡บ๐Ÿ‡ฆ|๐Ÿ‡บ๐Ÿ‡ฌ|๐Ÿ‡บ๐Ÿ‡ฒ|๐Ÿ‡บ๐Ÿ‡ณ|๐Ÿ‡บ๐Ÿ‡ธ|๐Ÿ‡บ๐Ÿ‡พ|๐Ÿ‡บ๐Ÿ‡ฟ|๐Ÿ‡ป๐Ÿ‡ฆ|๐Ÿ‡ป๐Ÿ‡จ|๐Ÿ‡ป๐Ÿ‡ช|๐Ÿ‡ป๐Ÿ‡ฌ|๐Ÿ‡ป๐Ÿ‡ฎ|๐Ÿ‡ป๐Ÿ‡ณ|๐Ÿ‡ป๐Ÿ‡บ|๐Ÿ‡ผ๐Ÿ‡ซ|๐Ÿ‡ผ๐Ÿ‡ธ|๐Ÿ‡ฝ๐Ÿ‡ฐ|๐Ÿ‡พ๐Ÿ‡ช|๐Ÿ‡พ๐Ÿ‡น|๐Ÿ‡ฟ๐Ÿ‡ฆ|๐Ÿ‡ฟ๐Ÿ‡ฒ|๐Ÿ‡ฟ๐Ÿ‡ผ|๐Ÿด๓ ง๓ ข๓ ฅ๓ ฎ๓ ง๓ ฟ|๐Ÿด๓ ง๓ ข๓ ณ๓ ฃ๓ ด๓ ฟ|๐Ÿด๓ ง๓ ข๓ ท๓ ฌ๓ ณ๓ ฟ|๐Ÿด๓ ต๓ ณ๓ ด๓ ธ๓ ฟ
@stamat
stamat / waiter.js
Created December 24, 2019 21:02
Simple recursive function that waits for DOM changes, used to wait for embedded-JS generated third party code, when no hook apparent or available
function waiter(selector, callback, timeout) {
var elem = document.querySelectorAll(selector);
if (!elem.length) {
if (timeout === undefined) {
timeout = 100;
}
setTimeout(function(){
waiter(selector, callback, timeout);
@stamat
stamat / slug.js
Created August 16, 2019 23:08
Wordpress like simple sanitize_title for javascript. Not checking for accents, since it is a slow process.
if (!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
};
}
function slug(s) {
s = s.toLowerCase().trim();
s = s.replace(/[^a-z0-9\s_-]/ig, '');
return s.replace(/[\s\uFEFF\xA0]+/ig, '-');
@stamat
stamat / _neat.scss
Created July 6, 2018 12:27
Neat 3.0.0 in one SASS file for Shopify theme dev
@charset "UTF-8";
// Neat 3.0.0
// http://neat.bourbon.io
// Copyright 2012 thoughtbot, inc.
// MIT License
/// This variable is a sass map that overrides Neat's default grid settings.
/// Use this to define your project's grid properties including gutters and
/// total column count.
///
@stamat
stamat / itetate_arguments.js
Last active December 31, 2015 20:59
A simple snippet for iterating arguments
var eachArg = function(args, fn, start_from, end_where) {
var i = start_from || 0;
while (i < args.length) {
if (end_where !== undefined && i === end_where)
return i;
if (fn !== undefined)
fn(i, args[i]);
i++;
}
return i;