Skip to content

Instantly share code, notes, and snippets.

@osvik
osvik / page-to-test.html
Last active July 11, 2021 22:00
Example on how to run tests in the browser. Running tests in the browser has advantages in many use cases as you can test the page in different mobile and desktop browsers and interact with the DOM.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example of simple javascript testing in the browser</title>
</head>
@osvik
osvik / .vimrc
Last active September 28, 2022 16:35
A very simple vim configuration
" Vim defaults
set nocp
" syntax highlighting
syntax on
" Show line numbers
set number
" Enable mouse

Alpinejs form components

Experiments to create forms with components. The idea is to use this with the Wordpress block editor.

@osvik
osvik / index.html
Created July 9, 2023 09:03
Animate CSS JavaScript enter and leave example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Animate CSS</title>
<!-- https://animate.style/ -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />
</head>
@osvik
osvik / ValidatePortugueseCitizenCard.js
Last active March 23, 2024 15:41
Functions to validate Portuguese Citizen Card, JavaScript and PHP
const validator = {
/**
* Validates Portuguese citizen card
* @param {string} value For example 15697354 5 ZZ1
* @returns {boolean}
*/
portugueseCitizenCard: function (value) {
const letterValue = {
A: 10, B: 11, C: 12, D: 13, E: 14, F: 15, G: 16, H: 17, I: 18, J: 19,