Skip to content

Instantly share code, notes, and snippets.

View atomjoy's full-sized avatar

Atomjoy atomjoy

View GitHub Profile
@atomjoy
atomjoy / code_htmlentities.php
Last active March 20, 2025 16:29
Czyszczenie tagów z html w php.
<?php
$code = '<h1>Article title goes here</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptate iste blanditiis ratione possimus in eum. Dolore assumenda eos, qui quia illo cumque ab recusandae dolor itaque nemo, tenetur minima doloribus?</p>
<style>pre {background: #fafafa; color: #010101;font-family:consolas;font-size:16px}</style>
<pre>
<code wow="error">
<span style="color: red;">Hello</span>
<?php
echo "hello from js";
@atomjoy
atomjoy / Html.php
Last active March 20, 2025 16:28
Html entities in php articles (Laravel, Vue).
<?php
namespace App\Validate;
use Throwable;
use DOMDocument;
/**
* Dla artykułu na bloga
* Zapisz normalnie html z textarea do bazy danych w laravelu
@atomjoy
atomjoy / code-line-numbers.css
Created March 20, 2025 11:31
CSS Pre code line numbers.
/*
Line numbers css
<pre>
<code>
<span class="line">Line 1</span>
<span class="line">Line 2</span>
<span class="line">Line 3</span>
</code>
@atomjoy
atomjoy / ChangeBg.vue
Last active March 22, 2025 10:37
Vue 3 css v-bind attributes, color and background image url (background-attachment fixed).
<script setup>
import { onBeforeMount } from 'vue';
let props = defineProps({
image: { type: String, default: '/default/default.webp' },
});
onBeforeMount(() => {
const img = new Image();
img.src = props.image;
@atomjoy
atomjoy / ChangeDescription.vue
Created March 22, 2025 09:57
Change page description in Vue 3.
<template></template>
<script setup>
import { watch, onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
const { t, locale } = useI18n({ useScope: 'global' });
const props = defineProps({
description: {
type: String,
@atomjoy
atomjoy / ChangeTitle.vue
Created March 22, 2025 09:58
Change page title in Vue 3.
<template></template>
<script setup>
import { useI18n } from 'vue-i18n';
import { watch, onMounted } from 'vue';
const { t, locale } = useI18n({ useScope: 'global' });
const props = defineProps({
title: {
type: String,
@atomjoy
atomjoy / ChangeTheme.vue
Created March 22, 2025 10:00
Change page theme in Vue 3.
<script setup>
import { onMounted, ref } from 'vue';
let th = ref('light');
th.value = localStorage.getItem('theme-xxx-theme') ?? 'light';
function update() {
document.querySelector('html').setAttribute('color-scheme', th.value);
}
@atomjoy
atomjoy / ChangeLocale.vue
Created March 22, 2025 10:01
Change locale in Vue 3.
<template>
<div class="change_locale">
<select v-model="locale" class="locale_select">
<option
v-for="lang in availableLocales"
:key="`locale-${lang}`"
:value="lang"
>
{{ t(lang) }}
</option>
@atomjoy
atomjoy / AddMeta.vue
Created March 22, 2025 10:04
Add page meta tags in Vue 3.
<template></template>
<script setup>
import { watch } from 'vue';
import { useI18n } from 'vue-i18n';
const { t, locale } = useI18n({ useScope: 'global' });
const props = defineProps({
json: {
type: [Array, Object],
@atomjoy
atomjoy / AddSchema.vue
Created March 22, 2025 10:05
Add page structured data in json in Vue 3.
<template></template>
<script setup>
import { watch } from 'vue';
const props = defineProps({
json: {
type: [Array, Object],
default: [],
},
});