## google apps script – Trouble bulk deleting mail from gmail

I’m on a list-serv that gets emails from crons for several hundred servers. The volume of emails is about 1G/week, so to keep from bumping up against my 15G disk quota, I have to delete messages periodically. I have a filter in Gmail that adds the label ‘label:inbox-zbark’ to these.

I use a search like this to find a week’s worth of emails:

``````label:inbox-zbark before:2018/12/16 after:2018/12/09
``````

Then I can select a week’s worth of messages by using the ‘select all’ button (which chooses the 100 conversations on the current page), then clicking the ‘Select all conversations that match this search’ button. I click the delete button and confirm the bulk action.

The problem is that above about 1000 conversations (which may have 100 emails a piece) gmail will either refuse to delete messages, or will throw an `oops` error. I can usually delete conversations 100 at a time, but this is very time consuming, and, at a certain point, gmail becomes markedly less responsive.

Gmail’s trash folder has similar issues. At a certain point, the ’empty trash’ button stops working… I can click the button, gmail will report `All messages have been deleted.`, but the messages still show in the trash folder.

I’m looking for a better way to mass delete emails, doing it through inbox is getting painful.

## JavaScript: proper user of SJCL encryption in Google Apps Script

I’m using the minified version of SJCL to encrypt the backup files requested by the users. It is in a Google Apps Script add-on for Google Sheets.

I’m mostly concerned with correct use, exception handling and best practices of adding the encryption part in the script. It is currently working as expected in backup and in restore process.

## The Backup (and Encryption)

### User enter passphrase

It starts by asking the user to enter and re-enter the passphrase in a prompt. 1) One concern here is that the text field of the prompt doesn’t mask the passphrase. To fix that I would show a dialog with HTML and form (password input). But then I would need to work client-server call and, while that is not an issue, the prompt is much simpler, less complicated and it won’t be necessary to put a HTML – that could be questionable by the user?

``````const passphrase1 = ui.prompt(
'Backup',
'Enter passphrase:',
ui.ButtonSet.OK_CANCEL);
if (passphrase1.getSelectedButton() === ui.Button.CANCEL) return 0;

const passphrase2 = ui.prompt(
'Backup',
ui.ButtonSet.OK_CANCEL);
if (passphrase2.getSelectedButton() === ui.Button.CANCEL) return 0;
``````

### Test passphrase

Here, the script tests if the passphrases match, and it also tests passphrase length and if it has at least upper, lower, numbers and special characters. It is a very simple test – so `pA\$\$w0rd00` pass the test – and I actually didn’t want to test anything like GnuPG does. In this case, is nothing (no test, like GnuPG) better than this simple test?

``````const passphrase = passphrase1.getResponseText();
if (passphrase !== passphrase2.getResponseText() || passphrase.length < 10 || testPassphrasePolicy(passphrase)) {
'Backup',
'Invalid passphrase.',
ui.ButtonSet.OK);
return 1;
}

function testPassphrasePolicy (passphrase) {
if (!/(a-z)+/.test(passphrase)) return 1;
if (!/(A-Z)+/.test(passphrase)) return 1;
if (!/(0-9)+/.test(passphrase)) return 1;
if (!/(~!@#\$%^*-_=+({)}/;:,.?)+/.test(passphrase)) return 1;

return 0;
}
``````

### Encrypt data

The encryption part is pretty straight forward. The `backup`is a object like `backup = { foe: 'abc', bar: 123 }`. The steps are as follow:

1. Stringify `backup`
2. Encode to base64
3. Compute SHA256
4. Concatenate the base64 with `:` and the SHA256
5. Encrypt with AES-128 in GCM mode and using the SHA256 as authentication data. If there is an error, simply return and show a generic message error.
6. Test decryption. If there is an error, simply return and show a generic message error.
7. Return a blob of the encrypted backup

I suspect steps 3 and 4 are overdoing, but before the addition of encryption that is how the script was doing an simple integrity test (with SHA1).

``````function encryptBackup_ (backup, passphrase) {
const string = JSON.stringify(backup);
const webSafeCode = Utilities.base64EncodeWebSafe(string, Utilities.Charset.UTF_8);

const sha = computeDigest('SHA_256', webSafeCode, 'UTF_8');
const data = webSafeCode + ':' + sha;

let encrypted = '';
try {
encrypted = sjcl.encrypt(passphrase, data, { mode: "gcm", adata: sha });
} catch (err) {
ConsoleLog.error(err);
return 0;
}

try {
const decrypted = sjcl.decrypt(passphrase, encrypted);
const parts = decrypted.split(':');
const test_sha = computeDigest('SHA_256', parts(0), 'UTF_8');

if (test_sha !== parts(1)) throw new Error('digestBackup_(): Bad decryption.');
} catch (err) {
ConsoleLog.error(err);
return 0;
}

const date = Utilities.formatDate(DATE_NOW, 'GMT', 'yyyy-MM-dd-HH-mm-ss');
const name = 'data' + date + '.backup';
const blob = Utilities.newBlob(encrypted, 'application/octet-stream', name);

return blob;
}
``````

## The Restore (and Decryption)

Once the user select a Drive `file`, the script requests the passphrase and tries to decrypt the file. This part is testing if it is possible to decrypt the file selected by the user.

The passphrase is being cached in a cache instance scoped to the current user and script so the script can retrieve it later to actually decrypt the file and restore the data. The cache expires in 120 seconds (session), and once it is retrieved later, it is immediately removed.

``````const ui = SpreadsheetApp.getUi();
const passphrase = ui.prompt(
'Restore',
'Enter passphrase:',
ui.ButtonSet.OK_CANCEL);
if (passphrase.getSelectedButton() === ui.Button.CANCEL) return 0;

let decrypted = null;

try {
decrypted = sjcl.decrypt(passphrase.getResponseText(), data);
} catch (err) {
ConsoleLog.error(err);
return 4;
}

'SHA_1',
'UTF_8');

const parts = decrypted.split(':');
const test_sha = computeDigest('SHA_256', parts(0), 'UTF_8');

if (test_sha !== parts(1)) return 4;

const string = base64DecodeWebSafe(parts(0), 'UTF_8');
return JSON.parse(string);
``````

## udev rule launches bash script at hotplug but not at coldplug/reboot

basically this udev rule at boot time , but I read somewhere that it was the systemd daemon that handles all the coldplug while udevd handles only the hotplugs.

How to do it with the linux systemd way instead of a python listener please?

## google sheets – How to solve situation where I need timestamp script to work on cell auto entry, not manual

can someone help me with this problem.
I have timestamp script running in google sheet and it work fine when I manually change value in cell. But I can’t find any solution how to have timestamp working when entry in trigger cell is some auto data from formula or such.
Or maybe if someone have another solution.
What I’m doing now is, from sheet1 with Query transfer data to sheet2 when some change is made.
When new row is created in sheet2 I want to have date of entry for every row that is created in sheet2, and date need to be fix all the time.

## Run PowerShell script as a different user and elevated

I know this looks like a duplicate question, but I’ve tried the solutions and they haven’t worked for me.

We need to run a script with our domain accounts but also make it elevated. This isn’t an issue on most devices, since the shortcut runs as admin, which prompts us for credentials. However if the user is a local admin, we are not prompted for credentials (just a yes/no UAC prompt).

I’m confused why this is not working:

``````# Get identity of script user
\$identity = (Security.Principal.WindowsPrincipal)(Security.Principal.WindowsIdentity)::GetCurrent()

# Elevate the script if not already
Write-Host -F Green 'ELEVATED'
} else {
Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"& '\$PSCommandPath'`""
Exit
}

# Ensure the script has domain privileges
} else {
Start-Process PowerShell -Verb RunAsUser "-NoProfile -ExecutionPolicy Bypass -Command `"& '\$PSCommandPath'`""
Pause # required, otherwise the Exit below closes the UAC prompt
Exit
}
Pause
``````

When the self-elevated script runs as user and domain credentials are entered, it loses elevation… i.e. when `Start-Process -Verb RunAsUser powershell` is run from an elevated PowerShell, it is not itself elevated.

I also tried the following:

``````Start-Process powershell -verb RunAs -argumentlist "Start-Process powershell.exe -Verb RunAsUser `"& pathtoscript.ps1`""
``````

Which fails because the domain admin does not have access to the script directory… unless they’re elevated.

## Bash script whitespace compliant – Code Review Stack Exchange

I have an huge amount of file to organize, they are a JPG files in an absurd folders structure.

I need to move all files from its actual position to an organized folder structure, saving its actually position as EXIF comment because in path there information to preserve.

For example I have a file with this path:

/OLD ARCHIVE/ORGANIZATION 1/1 FANTASTIC EVENT/1995 PIPPO does something.jpg

The destination will be something like: Archive Digital/AA/1995/CCC_BB_000002.jpg

My idea is to run the script from the OLD ARCHIVE/ path in order to have all information in the fname var. Then extract information from fname var and put them in exif (and in path), at the end, move the file logging what I’m doing.

I am writing this in bash, it was working but had some problem with whitespace management, so I tried to make it whitespace compliant…but it is not working anymore.

Can someone help me?

``````#!/bin/bash
#Parametri: CartellaOriginale CartellaOutput Prefisso NumeroIniziale Keywords
filenamePrefix="\$3"
data=\$(date +%F)
filelog="fileMovedLog_\$data.txt"
CommonKeywords="\$5"
echo "DEV Working on \$1"
echo "DEV output folder \$2"
echo "\$1/\$filelog"
echo "Backup in \${1%/}_BAK/"
#echo "\$data"
read -p "Press enter to continue"
echo 'Backup in corso'
#cp -R "\$1" "\${1%/}_BAK/"
echo 'Backup terminato, inizio elaborazione'
#mkdir "\$2"
touch "\$1/\$filelog"
find "\$1" -name "*.jpg" -or -name "*.JPG" -type f -not -path "*_BAK"| while read fname; do
echo "\$fname"
#Chiedo l'anno
forseAnno=\$(grep -oP  '(?<!d)d{4}(?!d)' <<< "\$fname")
if ( -z "\$forseAnno" )
then
forseAnno='ND'
fi
echo "Inserire cartella anno dove inserire la foto oppure lasciare vuoto se \$forseAnno"

if ( -z "\$annoIn" )
then #Se input è vuoto
anno="\$forseAnno"
else #ho input, metto lì.
anno="\$annoIn"
fi

#echo "\$anno"
#Keyword per Lightroom
#Estraggo alcune possibili KeyWord
string=\${fname,,}
extraKey=''
if grep -q 'palio' <<< "\$string"; then
extraKey=',palio del niballo'
fi
if grep -q 'dama' <<< "\$string"; then
extraKey="\${extraKey},dama"
fi
if grep -q 'not' <<< "\$string"; then
extraKey="\${extraKey},nott de biso"
fi
if grep -q 'cavaliere' <<< "\$string"; then
extraKey="\${extraKey},cavaliere"
fi
if grep -q 'bigorda' <<< "\$string"; then
extraKey="\${extraKey},bigorda"
fi
if grep -q 'corteo' <<< "\$string"; then
extraKey="\${extraKey},corteo"
fi
if grep -q 'paggi' <<< "\$string"; then
extraKey="\${extraKey},paggi"
fi
echo "\$extraKey"
read -e -p "Correggere le Keywords: " -i "\$anno,\$CommonKeywords\$extraKey" keyword </dev/tty
"exiftool -p -Keywords="\${keyword}" \${fname} -overwrite_original"
#Registro il precedente nome file nella descrizione
"exiftool -p -Description+="ERA: \${fname}" \$fname -overwrite_original"

#Sistemo la CreateDate
"exiftool -wm cg -CreateDate="\${anno}:01:01 00:00:00" -overwrite_original \${fname}"
if ( \$? -ne 0 ) #avevo già una data
then
datafile=("exiftool -S -createdate \$fname")
while true
do
if ( \$anno -lt 2021 ) #la scrittura della data in EXIF la faccio solo se è un anno minore di 2021. Se ho messo 5060 per indicare anni 50-60 non lo metto
then
read -e -p "Sovrascrivere la data \$datafile con \$anno?(Yes/No/Vuoto)" -i "Y" yn </dev/tty
else
read -e -p "Sovrascrivere la data \$datafile con \$anno?(Yes/No/Vuoto)" -i "N" yn </dev/tty
fi
case \$yn in
(Yy)* ) "exiftool -p -CreateDate=\${anno}:01:01 00:00:00' -overwrite_original";break;;
(Nn)* ) break;; #Non fo una sega
(0123456789)(0123456789)(0123456789)(0123456789)* ) "exiftool -p -CreateDate=\${yn}:01:01 00:00:00 -overwrite_original";break;;
* ) echo "Inserire Y(es)/N(o) o l'anno";;
esac
done
fi
#Procedo allo spostamento e logging
echo "Sposto \${fname} \${2}/\${anno}/\$filenamePrefix\$suffix.jpg"
read -p "Press enter to continue"
mv "\$fname" "\$2/\$anno/\$filenamePrefix\$suffix.jpg"
echo "\${fname}; \$filenamePrefix\$suffix.jpg" >>\$1/\$filelog
echo ""
done
echo "Completato";

$$```$$
``````

## How long does a HiddenEye keylogger script last in an Android browser?

I recently clicked on a phishing link and entered my credentials but then I changed the password. I believe the phisher used HiddenEye with a keylogger script in the webpage so how long can he capture my keystrokes for, after clicking the link I immediately closed the browser and cleared the cookies and seemed to find no malware when I did an antivirus scan but what if he enabled the keylogger script in my browser when I clicked the link, how do I find out?

## Rewrite php script – Code Review Stack Exchange

I have written one script in PHP which is defined here:

I am improving the code quality and readability. For example splitting it into multiple functions, use PHP predefined variables, use PSR naming conventions etc.

``````class nextcrontime{
//Get Single argument passed
function calculate_next_cron(){
If(isset(\$_GET('time')) && !empty(\$_GET('time'))){
\$splitime = explode(":", \$_GET('time'));
// Loop Content from config.txt line by line and perform required actions
\$list = explode(" ", \$line);

if(\$list(0) != '*' && \$list(1)=='*'){
\$newtime = \$splitime(0).":".\$list(0);
if(strtotime(\$newtime) >=  strtotime(\$_GET('time'))){
echo \$newtime." ".'Today'." ".\$list(2);
}else{
\$time = date('Y-m-d H:i', strtotime(\$newtime) + 60*60);
if (date("Y-m-d") > \$time) {
echo date("H:i", strtotime(\$time))." ".'Today'." ".\$list(2);
}else{
echo date("H:i", strtotime(\$time))." ".'Tomorrow'." ".\$list(2);
}
}
}
}else{
echo "Please Pass Time in HH:MM format. Example > php-cgi -f Index.php time=16:10.";
return;
}
//Close File Handler
}}}
``````

## Selling a casino script for a casino club Goldsvet 7.1 MRS

Our casino script is designed to create a club casino.
There are 954 games in the casino set.
The script has a convenient admin panel, cashier.
Our games are written in html5 and work on computers and phones!
We want to clarify that all casino games are source code!
The most important thing is that our script is not bound to a domain, and ip.
The casino has two unique templates (casino design).
We also provide detailed instructions on how to set up a casino (in case of difficulties, we will help you set up!)

We accept payment on a crypto wallet!
Price of a full casino set: 1500 euros

For all inquiries, contact the cantaks:
telegram: https://t.me/kseGB
mail: (email protected)

## javascript – Como trocar uma div de lugar com script?

Por exemplo eu tenho na página:

``````<div class="geral"></div>

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

<div class="geral-2"></div>
``````

Como colocar a segunda DIV em baixo da primeira com script ficando assim?

``````<div class="geral"></div>
<div class="geral-2"></div>

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
``````

Ps: Não tenho acesso ao código base por isso precisa mover usando script.