Find and replace

Find:       (:update\s.*)(_new)
Replace:    $1

Given text:

foo:update example_new
foo:update word_new
foo:update also_new

Output:

foo:update example
foo:update word
foo:update also

@blog #regex

Bulk Export

SQL-Insert-Statements-Bulk-100per.sql.groovy

SEP = ", "
QUOTE     = "\'"
NEWLINE   = System.getProperty("line.separator")

KEYWORDS_LOWERCASE = com.intellij.database.util.DbSqlUtil.areKeywordsLowerCase(PROJECT)
KW_INSERT_INTO = KEYWORDS_LOWERCASE ? "insert into " : "INSERT INTO "
KW_VALUES = KEYWORDS_LOWERCASE ? "values" : "VALUES"
KW_NULL = KEYWORDS_LOWERCASE ? "null" : "NULL"

OUT.append(KW_INSERT_INTO)
if (TABLE == null) OUT.append("MY_TABLE")
else OUT.append(TABLE.getParent().getName()).append(".").append(TABLE.getName())
OUT.append(" (")

COLUMNS.eachWithIndex { column, idx ->
    OUT.append(column.name()).append(idx != COLUMNS.size() - 1 ? SEP : "")
}

OUT.append(")").append(NEWLINE).append(KW_VALUES)

def record(columns, dataRow, close) {

    OUT.append(NEWLINE).append("(")
    columns.eachWithIndex { column, idx ->
        def value = dataRow.value(column)
        def skipQuote = value.toString().isNumber() || value == null
        def stringValue = value != null ? FORMATTER.format(dataRow, column) : KW_NULL
        if (DIALECT.getDbms().isMysql()) stringValue = stringValue.replace("\\", "\\\\")
        OUT.append(skipQuote ? "": QUOTE).append(stringValue.replace(QUOTE, QUOTE + QUOTE))
           .append(skipQuote ? "": QUOTE).append(idx != columns.size() - 1 ? SEP : "")
    }
    deliMeter = dataRow.last() || close ? ";" : ","
    OUT.append(")").append(deliMeter)
}

count = 0

def createInsert(columns, dataRow) {
    count++
    if (count%100 == 0 && !dataRow.last()) {
        record(columns, dataRow, true)
        OUT.append(NEWLINE).append(KW_INSERT_INTO)
        if (TABLE == null) OUT.append("MY_TABLE")
        else OUT.append(TABLE.getParent().getName()).append(".").append(TABLE.getName())
        OUT.append(" (")

        COLUMNS.eachWithIndex { column, idx ->
            OUT.append(column.name()).append(idx != COLUMNS.size() - 1 ? SEP : "")
        }

        OUT.append(")").append(NEWLINE).append(KW_VALUES)
        return
    }
    record(columns, dataRow, false)
}

ROWS.each { row -> createInsert(COLUMNS, row) }

mysql #groovy @blog

KDE Dive In

Apps

PHS 2019.1.4 
DGP 2019.2.6 custom JDK
DGP 2019.3 + plugin Choose Runtime + 8u212-linux-x64-b1596.1

latte launcher

subl ~/.config/kwinrc

[ModifierOnlyShortcuts]
Meta=org.kde.lattedock,/Latte,org.kde.LatteDock,activateLauncherMenu

OR

kwriteconfig5 --file ~/.config/kwinrc --group ModifierOnlyShortcuts --key Meta "org.kde.lattedock,/Latte,org.kde.LatteDock,activateLauncherMenu"

qdbus org.kde.KWin /KWin reconfigure

@blog #linux #kde

Dock station D3100

Fix slowing CPU

sudo nano /etc/X11/xorg.conf.d/20-intel.conf 

Section "Device"
  Identifier "Intel Graphics"
  Driver "Intel"
  Option "AccelMethod" "sna" 
  Option "TearFree" "true"
  Option "TripleBuffer" "true"
  Option "MigrationHeuristic" "greedy"
  Option "Tiling" "true"
  Option "Pageflip" "true"
  Option "ExaNoComposite" "false"
  Option "Tiling" "true"
  Option "Pageflip" "true"
  Option "VSync" "false"
EndSection

linux @blog

search lost info

git reflog --all | grep something
git fsck --full --no-reflogs --unreachable --lost-found | grep commit | cut -d\  -f3 | xargs -n 1 git log -n 1 --pretty=oneline > .git/lost-found.txt

@blog #git

Ubuntu Dive In

Frontend build

sudo apt-get install nodejs
sudo apt-get install npm
sudo npm install gulp-cli -g

npm install
gulp all-build 

Switch language

sudo apt-get install gnome-tweaks
gnome-tweaks

Keyboard & Mouse tab
Additional Layout Options button
Switching to another layout

Ctrl + Alt + Left/Right disable ubuntu

gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-left "['']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-right "['']"

Linux + Nvidia

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
ubuntu-drivers devices
sudo apt install <recommended>

Datagrip

Data source properties -> Options tab -> Object filter: collation:-.*

linux @blog

Fast create MySQL user and db with prevs

CREATE USER 'fast'@'%'
  IDENTIFIED WITH mysql_native_password AS '***';
GRANT USAGE ON *.* TO 'fast'@'%'
REQUIRE NONE
WITH MAX_QUERIES_PER_HOUR 0
  MAX_CONNECTIONS_PER_HOUR 0
  MAX_UPDATES_PER_HOUR 0
  MAX_USER_CONNECTIONS 0;
CREATE DATABASE IF NOT EXISTS `fast`;
GRANT ALL PRIVILEGES ON `fast`.* TO 'fast'@'%';
GRANT ALL PRIVILEGES ON `fast\_%`.* TO 'fast'@'%';

@blog

Projects

Tags

Capsule Servers

Lost connection to server.