Vuejs 2

Cheatsheet

Components understanding:

Preventing easy:

    <a href="#" @click.prevent="toDo();"></a>

Easy event handling:

    <button @click.ctrl="onClick">A</button>

    <button @click.ctrl.exact="onCtrlClick">A</button>

Prop validation:


Vue.component('example', { props: { // basic type check (`null` means accept any type) propA: Number, // multiple possible types propB: [String, Number], // a required string propC: { type: String, required: true }, // a number with default value propD: { type: Number, default: 100 }, // object/array defaults should be returned from a // factory function propE: { type: Object, default: function () { return { message: 'hello' } } }, // custom validator function propF: { validator: function (value) { return value > 10 } } } })

Mixins:


require('myapp-bootstrap'); require('./components/bootstrap'); var app = new Vue({ mixins: [require('myapp')] }); module.exports = { el: '#myapp-app', /** * The application's data. */ data: { }, }

@blog

Slack Desktop Dark Theme

  1. Use command to find slack folder: find / -name app.asar.unpacked -type d

  2. Append at the end of this file: app.asar.unpacked/src/static/ssb-interop.js

    document.addEventListener('DOMContentLoaded', function() {
         $.ajax({
           url: 'https://raw.githubusercontent.com/sandra1n/slack-night-mode/master/css/raw/black.css',
           success: function(css) {
             $("<style></style>").appendTo('head').html(css);
           }
         });
    });
    
  3. Restart App

@blog #linux

LibreOffice Calc Hints

How to swap a column in Calc:

Select column B

Click anywhere in the highlighted area and drag the column. The mouse pointer should change to show the drag operation.

Before you release the mouse button, also press the Alt key. When the mouse pointer is at the left side of column A, release the mouse button.

Column B should be moved to the left of column A so that A and B are switched.

linux @blog

PhpStorm

Hotkeys

Ctrl + ]           goto next bracket
Ctrl + Shift + ]   select all for next bracket
Ctrl + Shift + M   jump before or after closest bracket
ALT + Up | Down    next function
ALT + Home         breadcrumbs

Live templates

How to make dynamic class name:

Plugins

https://github.com/bodiam/intellij-bootstrap3

ide @blog

Nginx Application Server

Laravel

location / {
    proxy_pass       http://127.0.0.1:8300;
    proxy_redirect   http://127.0.0.1:8300/ /;
    proxy_read_timeout 60s;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

location ~ \.php$ {
    proxy_pass       http://127.0.0.1:8300;
    proxy_redirect   http://127.0.0.1:8300/ /;
    proxy_read_timeout 60s;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

Config

{                                                             
    "applications": {                                     
        "laravel": {                                     
            "type": "php 7.0",                    
            "user": "nobody",                     
            "group": "nobody",                    
            "workers": 2,                         
            "root": "/var/www/vhosts/laravel/public",
            "script": "index.php",                
        },     
    },
    "listeners": {                                        
        "*:8300": {                                   
                "application": "laravel"                 
        }                                           
    }     
}

nginx @blog

Message reminder

vi /path/to/message.sh

#!/bin/bash
PID=$(pgrep gnome-session)
dbus=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
export DBUS_SESSION_BUS_ADDRESS=$dbus
notify-send -u critical "$1"

crontab:

0 * * * * /path/to/message.sh "my message"

linux @blog

Ubuntu Service Autostart

vi /etc/systemd/system/mongodb.service

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target

systemctl start mongodb systemctl enable mongodb

vi /etc/systemd/system/elastic.service

[Unit]
Description=Port forwarding for 9200
After=network.target

[Service]
User=javelin
ExecStart=/usr/bin/ssh -NTC -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -R 9201:15.0.33.22:9200 user@host.com
RestartSec=3
Restart=always

[Install]
WantedBy=multi-user.target

systemctl start elastic

systemctl enable elastic

https://blog.kylemanna.com/linux/ssh-reverse-tunnel-on-linux-with-systemd/

linux @blog

Install Xdebug for PHP Ubuntu

Prepare to install:

apt install php7.0-xdebug
php --version

Find xdebug path (latest by year):

find / -name 'xdebug.so' 2> /dev/null

Config update vi /etc/php/7.0/fpm/php.ini:

zend_extension="/usr/lib/php/20160303/xdebug.so"
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_handler="dbgp"
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_mode=req
xdebug.overload_var_dump=off
xdebug.idekey = PHPSTORM
xdebug.max_nesting_level = 512
xdebug.file_link_format = phpstorm://open?%f:%l

Then restart:

service php7.0-fpm restart

php #debug @blog

Projects

Tags

Capsule Servers

Lost connection to server.