Kategorien
Allgemein CSS FlexBox

Flex-Box Tricks

display:flex instead inline-block

To use the exact size of element you can use better display:flex instead inline-block.
Standard inline-block, in this case we have some space under the element
display:flex, only use element size

Use margin-right:auto sometines helpfully instead using justify-content

Next Example, here margin:auto pushed all the way to the right side. If we are using display:flex and justify-content in parent element you can do same things, but sometimes wie have more elements and then space-arounding, space-between doesnt help for exactly positioning.

Kategorien
Allgemein Vue

Custom Directive

Eigene Directive (focus), die nach dem die App fertig gemountet wurde den focus auf Elemente setzt.

# /directive/focus.js
export default {
    mounted(el){
        el.focus();
    }
}

Globale Einbindung der Directive

import { createApp } from 'vue'
import App from './App.vue'

import logger from './mixins/logger';
import focus from './directive/focus';

const app = createApp(App);
app.mixin(logger)
app.directive('focus',focus)
app.mount('#app')

Verwendung der Directive

Bezeichner v- voranstellen

 <input
      type="text"
      class="form-control"
      placeholder="Neue Aufgabe"
      v-model="content"
      v-focus
    />

Kategorien
Allgemein Vue

MIXINS

  • besitzt das mixin gleiche Attribute oder Methoden, wie auch die Komponente, werden diese zusammengeführt
  • bei gleichen Methodennamen in Mixin und Komponente hat die der Komponente Vorrang und die mixin-Methode verfällt
    Methodenname daher entsprechend anpassen
  • Life-Cycle Hooks (mounted) haben in den Mixins Vorrang, dann erst die Hooks aus der Komponente

LOKALE EINBINDUNG

# /mixin/logger.js  - mounted und methods
export default {
    mounted(){
        this.writeLogEntry(`${this.$options.name}-Component vollständig geladen`);
    },
    methods: {
        writeLogEntry(text){
            console.log(text);
        }
    }
}
#App.vue - verwendet mixin und hat eigene method und mounted
export default {
  name: "App",
  mixins: [logger],
  components: {
    StatusCard,
  },
  mounted(){
    console.log("APP Komponente vollständig geladen");
  },

GLOABALE EINBINDUNG

#main.js
import { createApp } from 'vue'
import App from './App.vue'

import logger from './mixins/logger';

const app = createApp(App);
app.mixin(logger)
app.mount('#app')
Kategorien
Allgemein Vue

Slots

Daten von außen nach innen reichen. Slots sind Platzhalter, die von außen gefüllt werden. So kann bspw. vorgegeben werden welche Angaben erwartet werden.

#default
<slot></slot>
<slot name="title"></slot>


Von außen angesteuert:
<template v-slot:title>Text der durchgereicht wird</template>

Kurzschreibweise
<template #title>Titeltext</template>

Freigabe von Daten von innen nach aussen

Definition Slot-Name
<slot name="eventdaten" :eventNameVonAussen="eventDaten"></slot>

Ansteuerung Slot mit Namen
<template #eventdaten="slotProps">{{ slotProps.eventDaten }}</template>

Die Daten werden nach aussen gereicht, Vue sammelt alle Daten, Funktion, Objekte. Wir bestimmen "slotProps" in dem alles gesammelt wurde. Name frei wählbar.

Kategorien
Allgemein

XSD Validierung direkt im XML

XML mit XSD validieren

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="validation_xsd.xsd">
    <event>
        <event_id>1</event_id>
        <event_name>ICPC</event_name>
        <event_desc>5 coding questions in 2 hrs</event_desc>
        <event_tags>
            <tag id="1" displayName="coding">coding</tag>
        </event_tags>
        <event_type_participation>Team</event_type_participation>
        <event_timing>
            <event_start_datetime>2020-04-01T10:00:00</event_start_datetime>
            <event_end_datetime>2020-04-01T12:00:00</event_end_datetime>
        </event_timing>
        <event_organizer_email>abc@gmail.com</event_organizer_email>
        <event_organizer_phone>1234567890</event_organizer_phone>
    </event>
</root>
Kategorien
Allgemein Befehle Linux

Certbot renew Certificate or add new Domain





sudo /usr/local/bin/certbot-auto --apache
sudo systemctl restart httpd

Kategorien
Allgemein Mysql,MariaDB

Export and Import all MySQL databases at one time

Export all Databases and Tables

mysqldump -u root -p --all-databases > alldb.sql

// Sometimes problems with tablespaces then use
mysqldump -u root -p --all-databases > alldb.sql

SINGLE Database

mysqldump -u root -p db1 db2 dbx > alldb.sql

mysqldump -u root -p db1 db2 dbx > db.sql

#some hoster have sometimes problems with tablespaces
mysqldump -h hostnameOrIp -u root -p --no-tablespaces db1 db2 dbx > alldb.sql

INNODB Database Export

mysqldump.exe -u root -v --single-transaction --single-transaction --skip-lock-tables database_name_to_export > filename.sql

-v show all exporting line
–single_transaction flag will start a transaction before running. Rather than lock the entire database, this will let mysqldump read the database in the current state at the time of the transaction, making for a consistent data dump.

Import Databases

All Databases

mysql> sudo mysql -u root -p db_name < export.sql

Single Database

mysql> CREATE DATABASE db_name;
mysql> sudo mysql -u root -p db_name <  export.sql

Kategorien
Allgemein

Samba unter Centos 8

  1. Installation
sudo dnf install samba samba-common samba-client

2.Konfiguration

sudo mv /etc/samba/smb.conf /etc/samba/smb.con.bak

smb.conf

sudo nano /etc/samba/smb.conf
[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = centos-8
security = user
map to guest = bad user
dns proxy = no

[Anonymous]
path = /srv/samba/shared
browsable =yes
writable = yes
guest ok = yes
read only = no

Mit Authorisierung

$ sudo mkdir -p /srv/samba/shared
$ sudo chmod -R 0755 /srv/samba/shared
$ sudo chown -R nobody:nobody /srv/samba/shared
$ sudo chcon -t samba_share_t /srv/samba/shared

...am Ende zur smb.conf hinzufügen

[Share01]
        # specify shared directory
        path = /home/share01
        # allow writing
        writable = yes
        # not allow guest user (nobody)
        guest ok = no
        # allow only [smbgroup01] group
        valid users = @smbgroup01
        # set permission [777] when file created
        force create mode = 777
        # set permission [777] when folder created
        force directory mode = 777
        # inherit permissions from parent folder
        inherit permissions = yes 

Ohne Authorisierung

$ sudo mkdir -p /srv/samba/mycloud
$ sudo chmod -R 0755 /srv/samba/mycloud
$ sudo chown -R nobody:nobody /srv/samba/mycloud
$ sudo chcon -t samba_share_t /srv/samba/mycloud

...am Ende zur smb.conf hinzufügen

[mycloud]
        # specify shared directory i.e. /srv/samba/private or 
        path = /home/mycloud oder 
        browseable = yes
        # allow writing
        writable = yes
        # not allow guest user (nobody)
        guest ok = yes

...SELinux allow Samba to read and write
$sudo chcon -t samba_share_t /srv/samba/mycloud -R

Konfigurationdatei testen...
$ testparm

Sambaserice neu starten
$ sudo systemctl restart {smb,nmb}

Firwallzugriff erlauben
$ sudo firewall-cmd --add-service=samba --zone=public --permanent $ sudo firewall-cmd --reload

Verbindungsfehler – Connection Errors

You do not have permission to access \\hostname\sharename. Contact your network administrator to request access.

Manchmal muss die alte Session erst beendet werden, bevor eine neue erstellt werden kann

net user \\samber-server-ip\share-name /delete

net user \\samber-server-ip\share-name /user:samba-user-password

Kategorien
Allgemein Git

.gitignore

How do I prevent .gitignore from being committed?

//open file in your local project and adding files or directories
//which excluded from commiting
.git/info/exclude

Kategorien
Allgemein IDE Stacks

XDebug with Postman

Normally we rely on browser extension to debugging with PHPStorm /VisualCode and XDebug. But Postman is an own application, so i couldnt install any extension.

The trick 🙂 only append to the end „http://myurl/service?XDEBUG_SESSION_START=PHPSTORM