This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Client configs, 16.04, | |
script-security 2 | |
up /etc/openvpn/update-resolv-conf | |
down /etc/openvpn/update-resolv-conf | |
# network manager, 16.04, install below package to enable import openvpn client configs | |
sudo apt install network-manager-openvpn-gnome | |
# Client configs, 18.04/18.10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
what's going to be deleted: | |
find ~/.cache/ -depth -type f -atime +365 | |
deleted (last accessed more than a year ago) | |
find ~/.cache/ -type f -atime +365 -delete |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rotate the files first so that recent entries are moved to inactive files | |
journalctl --rotate | |
Retain only the past two days: | |
journalctl --vacuum-time=30d | |
Retain only the past 500 MB: | |
journalctl --vacuum-size=500M |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// constants / params | |
const key = CryptoJS.enc.Utf8.parse('example-key'); | |
const iv = CryptoJS.enc.Utf8.parse('example-iv'); | |
// functions | |
function CryptJsWordArrayToUint8Array(wordArray) { // https://github.com/brix/crypto-js/issues/274 | |
const l = wordArray.sigBytes; | |
const words = wordArray.words; | |
const array = new Uint8Array(l); | |
let i=0; /*dst*/ | |
let j=0; /*src*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Example</title> | |
<style> | |
button { | |
padding: 10px; | |
background-color: #3C79F8; | |
display: inline-block; | |
} | |
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chrome.browserAction.onClicked.addListener(function() { | |
chrome.tabs.create({url: 'index.html'}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Manifest Example", | |
"description" : "Drive API Manifest in Chrome Extension", | |
"version": "1.0", | |
"permissions": [ | |
"identity" | |
], | |
"background": { | |
"scripts": ["background.js"], | |
"persistent": false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// function within window | |
window.onload = function() { | |
// button behaviours | |
document.querySelector('button') | |
.addEventListener( | |
'click', | |
function() { | |
// get Auth Token | |
chrome.identity.getAuthToken({interactive: true}, function(token) { | |
console.log(token); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var DriveBaseUrl = 'https://www.googleapis.com/'; | |
var DriveWriteUrl = 'upload/drive/v3/files/'; | |
// write file - update with Array Buffer | |
fetch( | |
DriveBaseUrl + DriveWriteUrl + fileId, | |
{ | |
method: 'PATCH', | |
headers: { | |
Authorization: 'Bearer ' + token, | |
'Accept': 'text/plain', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const DriveRenameUrl = 'https://content.googleapis.com/drive/v3/files/'; | |
// rename file - fetch | |
fetch( | |
DriveRenameUrl + fileId + '?alt=json', | |
{ | |
method: 'PATCH', | |
headers: { | |
Authorization: 'Bearer ' + token, | |
'Accept': 'application/json', | |
'Content-Type': 'application/json' |
NewerOlder