Skip to content

Instantly share code, notes, and snippets.

@eszterkv
eszterkv / countries.js
Created July 30, 2019 12:21
List of countries of the world with name and 2- and 3-letter countrycodes
const allCountries = [
{name: 'Australia', code: 'AUS', code2: 'AU'},
{name: 'Canada', code: 'CAN', code2: 'CA'},
{name: 'Finland', code: 'FIN', code2: 'FI'},
{name: 'Ireland', code: 'IRL', code2: 'IE'},
{name: 'Japan', code: 'JPN', code2: 'JP'},
{name: 'Norway', code: 'NOR', code2: 'NO'},
{name: 'South Africa', code: 'ZAF', code2: 'ZA'},
{name: 'Sweden', code: 'SWE', code2: 'SE'},
{name: 'United Kingdom', code: 'GBR', code2: 'GB', alt: ['Great Britain', 'England', 'UK']},
@eszterkv
eszterkv / pre-commit.sh
Last active September 1, 2019 15:27
Pre-commit git hook that runs all unit tests before commit
yarn test
RESULT=$?
if [ $RESULT == 1 ]; then
echo "Commit rejected: some tests failed. Please fix the tests before committing."
exit 1
fi
@eszterkv
eszterkv / create-nextjs-sitemap.js
Created September 1, 2019 15:30
Create XML sitemap for Next.js projects
#! /usr/bin/env node
const path = require('path');
const glob = require('glob');
const fs = require('fs');
const SITE_ROOT = 'https://example.com';
const SOURCE = path.join(__dirname, '..', 'pages', '/**/*.js');
const DESTINATION = path.join(__dirname, '..', 'static', 'sitemap.xml');
@eszterkv
eszterkv / machine.js
Last active April 20, 2021 16:25
Generated by XState Viz: https://xstate.js.org/viz
const signUp = Machine({
id: 'signup',
initial: 'init',
context: {
retries: 0
},
states: {
init: {
on: {
@eszterkv
eszterkv / hmoa_menu_quickfix.js
Created April 16, 2025 08:52
hmoa menu quickfix
var menu = document.querySelector('.mobile-menu');
var btn = document.querySelector('.nav-toggle');
btn.addEventListener('click', function() {
if (menu.hasAttribute('style')) {
var display = menu.style.display;
menu.setAttribute('style', `display: ${display === 'none' ? 'initial' : 'none'}`);
} else {
menu.setAttribute('style', 'display: initial');
}