Code samples for the article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class MarkoNativeShare extends HTMLElement { | |
pictureElement?: HTMLPictureElement | null | |
images?: HTMLImageElement[] | null | |
loaded = false | |
connectedCallback() { | |
this.pictureElement = this.querySelector('picture') | |
if (!this.pictureElement) { | |
throw new Error('<x-image>: requires a <picture> element') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule PentoWeb.UploadLive do | |
use PentoWeb, :live_view | |
# @bytes_for_5MB 5_242_880 | |
@bytes_for_5MB 1_000_000 | |
@impl Phoenix.LiveView | |
def mount(_params, _session, socket) do | |
socket = | |
socket |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! tailwindcss v2.2.19 | MIT License | https://tailwindcss.com *//*! modern-normalize v1.1.0 | MIT License | https://github.com/sindresorhus/modern-normalize */*,:before,:after{box-sizing:border-box}html{-moz-tab-size:4;-o-tab-size:4;tab-size:4}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"}hr{height:0;color:inherit}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}button,[type=button],[type=res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="flex items-center justify-center bg-gray-100 h-screen"> | |
<DialogsDemo /> | |
</div> | |
<Dialogs :state="dialogState" /> <!-- This is important --> | |
</template> | |
<script> | |
import { provideDialogs } from "./composables/useDialog.js"; // This is important |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use App\Support\Utils\OctaModal; | |
use App\Support\Utils\OctaResponse; | |
use Illuminate\Support\Facades\Cache; | |
use Illuminate\Support\Facades\Session; | |
use Illuminate\Support\ServiceProvider; | |
use Inertia\Inertia; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let value; | |
value = String( -0 ); | |
console.log(value); // "0" OOPS! | |
value = String( null ); | |
console.log(value); // "null" | |
value = String( undefined ); | |
console.log(value); // "undefined" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let value; | |
value = Number(""); | |
console.log(value); // 0 OOPS! | |
value = Number(" \t\n"); | |
// what happens here is that toNumber strips all white space! | |
// leaving the string "" which, remember converts to 0 | |
console.log(value); // 0 OOPS! | |
value = Number(null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NaN (not a number) | |
let name = "Mykolas"; | |
let something = name / 4; | |
console.log(typeof something); // number | |
something; // NaN | |
console.log(Number.isNaN(something)); // true | |
console.log(Number.isNaN(name)); // false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let variable; | |
console.log(typeof variable); // undefined | |
variable = "1"; | |
console.log(typeof variable); // string | |
variable = 2; | |
console.log(typeof variable); // number | |
variable = true; |
NewerOlder