Skip to content

Instantly share code, notes, and snippets.

@adinan-cenci
adinan-cenci / update-uuids.php
Last active April 9, 2024 17:57
update-uuids.php
<?php
/**
* How to use:
*
* chmod +x update-uuids.php
* php update-uuids.php @site.stager @site.live
*
* It will output a series of sql queries to be run on stager's mysql server.
*
@adinan-cenci
adinan-cenci / list-desktop-shortcuts.sh
Created October 20, 2022 11:45
List all .desktop files on the system
#!/bin/bash
# At the moment this will list all the .desktop files on the system
# even the ones not currently installed
# Setting IFS (input field separator) value as ":"
IFS=':'
# Reading the split string into array
read -ra arr <<< "$XDG_DATA_DIRS"
@adinan-cenci
adinan-cenci / installing.md
Last active March 17, 2024 10:05
Custom cheats for Project Brutality

Installing GzDoom

  1. Install with flatpak.
  2. Go to internet archive and download the iwad files.
  3. Extrac to ~/.var/app/org.zdoom.GZDoom/.config/gzdoom.

Installing Project brutality

  1. Download the source code from the github page.
  2. Decompress it.
  3. Enter the Project_Brutality_master folder and compress its content again.

Comparing differences between entities

/**
 * Compares the current state of an entity with its previous version
 * to check if it has been updated.
 *
 * @param EntityInterface $currentEntity
 *  The entity object.
 *
@adinan-cenci
adinan-cenci / App.vue
Last active February 25, 2023 15:27
Vue + Webpack + Gulp
<script>
export default {
data() {
return {
theTruth: 'Vue used to be way easier to get into, now it is as complicated as other garbage like angular and react',
}
},
}
</script>
@adinan-cenci
adinan-cenci / _how-to-use-slots-without-shadow-dom.md
Last active March 7, 2021 01:40
Using <slot> tags in custom elements without the shadow dom.

Using <slot> tags in custom elements without shadow dom

The <slot> tag is very useful when creating custom elements. However, this feature is only available with the use of shadow dom, the downside being that we can't use the parent document's css to style the shadow dom.

So we either copy the css into the shadow dom or don't use slots at all.

In this snippet we'll see how to circumvent this limitation with the use of a MutationObserver object.

@adinan-cenci
adinan-cenci / _fetch-form.md
Last active June 20, 2024 20:46
How to follow upload progress with fetch()

How can we follow the upload progress with fetch() ?

Simple: We can't.
Not right now anyway, fetch() does not support that, but good old XMLHttpRequest does though.

The function below behaves much like fetch(), it will return a Promise that will resolve into a Response object.

Just pass a progress function in the options parameter.

@adinan-cenci
adinan-cenci / get-query-string-variables-with-javascript.md
Last active May 2, 2022 13:46
Get variables from the query string

Get query string variables

Lets say you have accessed an url on your site https://my-website.com/search?q=product-x&maxprice=300.
How can you get the variables search or maxprice in javascript ?

You can use this function:

function get(varName, alternative = null) 
{
@adinan-cenci
adinan-cenci / _README.md
Last active October 12, 2021 23:24
How to parse HTML with javascript

Parsing HTML with JavaScript

Javascript provide us with the DOMParser class to parse XML/HTML into DOM.

But sometimes we will end up dealing with invalid html, the DOMParser do not provide a way to deal with syntax errors, it will simply stop and leave us hanging.

Another way would be to use document.implementation.createHTMLDocument.

@adinan-cenci
adinan-cenci / get-an-element-s-position.markdown
Last active December 28, 2019 12:31
Get an element's position