dir 'e:\' -recurse -force | Where-Object { $_.LinkType -and ($_.FullName -notlike '*\.pnpm-store*' -or $_.FullName -notlike '*\.git*') } | Select-Object FullName, LinkType, Target
#windows #powershell #filesystem
// injects the script in the body of the document. | |
// returns a promise that gets resolves once the script has been loaded in the document | |
export const injectScript = (url, document = window.document) => { | |
const script = document.createElement('script'); | |
script.src = url; | |
script.type = 'text/javascript'; | |
script.async = true; | |
const body = document.getElementsByTagName('body')?.[0] ?? null; | |
if (body === null) { |
## Pre-requisite: You have to know your last commit message from your deleted branch. | |
git reflog | |
# Search for message in the list | |
# a901eda HEAD@{18}: commit: <last commit message> | |
# Now you have two options, either checkout revision or HEAD | |
git checkout a901eda | |
# Or | |
git checkout HEAD@{18} |
dir 'e:\' -recurse -force | Where-Object { $_.LinkType -and ($_.FullName -notlike '*\.pnpm-store*' -or $_.FullName -notlike '*\.git*') } | Select-Object FullName, LinkType, Target
#windows #powershell #filesystem
...instead of sprintf
or str_replace
[^1] in #php #string #template #pitfall
$strTemplate = "My name is :name, not :name2.";
$strParams = [
':name' => 'Dave',
'Dave' => ':name2 or :password', // a wrench in the otherwise sensible input
':name2' => 'Steve',
':pass' => '7hf2348', // sensitive data that maybe shouldn't be here
#dto #data-transfer-object #php
Based on https://github.com/spatie/data-transfer-object/tree/v2
$object = [
'parameters' => [
[
'name' => 'foo',
'type' => 'text',
#js
fetch
.then()
part to the fetch()
and send the requestfetch("https://teeeeeessssstttttt.com/ticket/", {
// This is meant to be in a html head script tag | |
// checkboxes are very inconvenient in html and will serialize nothing when the checkbox is unchecked | |
// instead of using hx-vals and writting a bit of JSON each time you have a checkbox I decided to fix it globally: | |
window.onload = function() { | |
document.body.addEventListener('htmx:configRequest', function(evt) { | |
const isInput = evt.detail.elt.tagName == 'INPUT'; | |
const isCheckbox = evt.detail.elt.type == 'checkbox'; | |
const isNotChecked = evt.detail.elt.checked == false; | |
if(isInput && isCheckbox && isNotChecked) { | |
const name = evt.detail.elt.name; |
All the ways to make a Web Component (native and Alpine.js) #webcomponents #alpinejs
https://webcomponents.dev/blog/all-the-ways-to-make-a-web-component/
const template = document.createElement('template');
template.innerHTML = `
<style>
* {
font-size: 200%;
}
Just a little demo how to use bootstraps toasts component with HTMX and custom triggers. Toasts are stackable and grouped by message (so the same message doesn't pop up several times, when already open.
A Pen by Marcus at Localhost on CodePen.