Skip to content

Instantly share code, notes, and snippets.

View Neophen's full-sized avatar

Mykolas Mankevicius Neophen

View GitHub Profile
@Neophen
Neophen / marko_image.ts
Last active March 30, 2024 09:17
LiveView Hooks vs WebComponents
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')
}
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
@Neophen
Neophen / index.css
Created November 15, 2021 14:43
Peer utilities issue
/*! 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
@Neophen
Neophen / App.vue
Created June 11, 2021 05:07
Vue.js Snippets - useDialog
<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
@Neophen
Neophen / readme.md
Last active March 16, 2021 15:12
Spa Error handling

Handle API Errors in vue spa

Code samples for the article

<?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;
@Neophen
Neophen / string-coersion.js
Created August 2, 2019 08:53
String coercion
let value;
value = String( -0 );
console.log(value); // "0" OOPS!
value = String( null );
console.log(value); // "null"
value = String( undefined );
console.log(value); // "undefined"
@Neophen
Neophen / number-coersions.js
Created August 2, 2019 08:31
Number coercion weirdness!
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);
@Neophen
Neophen / NaN.js
Created August 1, 2019 10:54
NaN ( not a number )
// 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
let variable;
console.log(typeof variable); // undefined
variable = "1";
console.log(typeof variable); // string
variable = 2;
console.log(typeof variable); // number
variable = true;