20191028

VirtualBox 調整CentOS VM硬碟大小配置

"c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd Core20-Comp-03-disk1.vdi --resize 25000

接下來進入VM以root執行以下指令
fdisk /dev/sda
d
2
n
p
2
ENTER
ENTER
w
reboot
pvresize /dev/sda2
pvscan
lvextend -l +100%FREE /dev/mapper/centos_core20--desktop--1-root
xfs_growfs /dev/mapper/centos_core20--desktop--1-root
df -h


20181212

xml2json

function xml2json($fileContents) {
  $fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents);
  $fileContents = trim(str_replace('"', "'", $fileContents));
  $simpleXml = simplexml_load_string($fileContents);
  $json = json_encode($simpleXml,1);
  return $json;
}

20171205

Linode Centos7 / install Desktop and Vncserver

***Desktop***
yum -y update
yum -y groupinstall "GNOME Desktop"
ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target
yum -y install epel-release
yum -y update
yum clean all
yum -y groupinstall "X Window system"
yum -y groupinstall "MATE Desktop"
systemctl set-default graphical.target

#安裝 倉頡輸入法 套件
#http://oldgrayduck.blogspot.tw/2016/12/centos7.html
yum -y install ibus-table-chinese-cangjie


***VNCSERVER***
yum -y install tigervnc-server
useradd se
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
vi /etc/systemd/system/vncserver@:1.service
  #change -> se

firewall-cmd --permanent --zone=public --add-service vnc-server
firewall-cmd --reload
su se
vncserver
  #set password
su -
systemctl daemon-reload
systemctl enable vncserver@:1.service
reboot
systemctl start vncserver@:1.service

20160803

[備忘]Chrome Clear History

chrome://history-frame/
In the Console Debugger/Viewer, copy & paste the following code:
function removeItems() {
removeButton = document.getElementById('remove-selected');
overlayWindow = document.getElementById('overlay');
    //revision (07.28.15): Replaced the For Loop targeting the checkboxes, thanks to Denis Gorbachev via comments (02.19.15)
Array.prototype.forEach.call(document.querySelectorAll("input[type=checkbox]"), function(node) {node.checked = "checked"})
setTimeout(function () {
    if (removeButton.getAttribute("disabled") !== null) {
        removeButton.removeAttribute("disabled")
    }
    /* revision (08.20.14): no longer binding to that condition, button should no longer be disabled, so click! */
    if ((overlayWindow.hasAttribute("hidden")) && (overlayWindow.getAttribute("hidden") !== false)) {
        removeButton.click();
    }
    /* revision (08.20.14): new Interval, to check against the overlay DIV containing the confirmation "Remove" button */
    /* Attempting to click the button while the DIV's "hidden" attribute is in effect will cause FAILED ASSERTION */
    stopButton = setInterval(function () {
        if (overlayWindow.hasAttribute("hidden")) {
            if (overlayWindow.getAttribute("hidden") == "false") {
                hidden = false
            } else {
                hidden = true
            }
        } else {
            hidden = false
        }
        if (!hidden) {
            document.getElementById("alertOverlayOk").click();
            clearInterval(stopButton)
        }
    }, 250)
}, 250)
}
//revision (08.20.14): Lets build our buttons to control this so we no longer need the console
//stop button (08.20.14)
var stopButton = document.createElement('button');
stopButton.setAttribute('id', "stopButton");
stopButton.innerHTML = "Stop";
stopButton.style.background = "#800";
stopButton.style.color = "#fff";
stopButton.style.display = "none";
stopButton.onclick = function () {
    clearInterval(window.clearAllFiltered);
    document.getElementById("stopButton").style.display = "none";
    document.getElementById("startButton").style.display = ""
};
//start button (08.20.14)
var startButton = document.createElement('button');
startButton.setAttribute('id', "startButton");
startButton.innerHTML = "Start";
startButton.style.background = "#090";
startButton.style.color = "#fff";
startButton.onclick = function () {
    window.clearAllFiltered = setInterval(function () {
/* revision (07.28.15): Stop the Loop automatically if there are no more items to remove */
        if(document.getElementById("results-header").innerText=="No search results found."){
            document.getElementById("stopButton").click();
            }
        if (document.getElementById("loading-spinner").getAttribute("hidden") !== null) {
            removeItems()
        }
    }, 250); //adjust Time Here (1500 [millisec] = 1.5sec)
    document.getElementById("stopButton").style.display = "";
    document.getElementById("startButton").style.display = "none"
};
/* revision (08.20.14): Now we add our buttons, and we're ready to go! */
editingControls = document.getElementById('editing-controls');
editingControls.appendChild(stopButton);
editingControls.appendChild(startButton);

20160711

IPTABLES DUMP / RESTORE

Backup
# iptables-save > /root/iptables.bak
Restore
# iptables-restore < /root/iptables.bak