Skip to content

Instantly share code, notes, and snippets.

View osvik's full-sized avatar
💭
Working

Osvaldo osvik

💭
Working
View GitHub Profile
@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,
@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>

Alpinejs form components

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

@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
@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>
<?php
/**
* Añade capacidades a editores y admins
*/
function editor_unfiltered_upload( $caps, $cap, $user_id ) {
if ( "unfiltered_upload" === $cap && user_can( $user_id, "editor" ) ) {
$caps = array( "unfiltered_upload" );
}

SVGjs CHEAT SHEET

More info...

Begining of the svg file

Adobe Illustrator will give you something like this, but you must add the width and height attributes based in the viewBox.

<?xml version="1.0" encoding="utf-8"?>
@osvik
osvik / dynamic.html
Created March 25, 2019 20:29
Responsive elements based on parent column width
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Responsive elements based on parent column width</title>
</head>
<body>
@osvik
osvik / embedded.html
Last active March 24, 2019 21:24
Really responsive iframes! Gets the iframe height from the embedded html document
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Embedded html document</title>
<style>
html,
body {
margin: 0;