Skip to content

Instantly share code, notes, and snippets.

View clementsjj's full-sized avatar

JJ Clements clementsjj

View GitHub Profile
@clementsjj
clementsjj / tail-exclude.sh
Created July 13, 2021 17:46
Script that excludes a line that includes a word from tail output
#!/bin/bash
tail -F /var/log/apache2/access.log | while read LINE;do
if [[ ! "$LINE" =~ "excludethisphrase" ]]; then
echo $LINE
fi
done

kill $(lsof -ti:3000)

netstat -vanp tcp | grep 3000

const sleep = (waitTime) => new Promise(resolve => setTimeout(resolve, waitTime));
await sleep(1000)
// Following will poll only the rows for Staten Island
// ✓ Staten Island
// ✓ Queens
// ✓ Brooklyn (4,000,000 / maxComplaintNumResult[2])
// ✓ Bronx (3,000,000 / maxComplaintNumResult[1])
// ✓ Manhattan (2,000,000 / maxComplaintNumResult[0])
const highNum = 2000000;
const whereStatement = `complaint_number<'${highNum}' AND complaint_number>='${maxComplaintNumResult[0]}'`;
const statenIslandComplaints = await publisher(
datasetIdentifier,

opendiff kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff diffuse diffmerge ecmerge

const cleanBoolean = (
x: any,
trueValue: string,
falseValue: string,
onNull = null
): boolean | null => {
if (x === trueValue) {
return true;
}
if (x === falseValue) {
const cleanString = (s: string): string => {
const words = s.trim().split(/\s+/);
return words.join(' ');
};

To Note: While running with await in the for loop, everything executed as expected When changed to a Promise.all() solution IOT adhere to an es-lint rule, the complaintNo for Manhattan ('1') is not returned According to es-lint: https://eslint.org/docs/rules/no-await-in-loop "performing an await as part of each operation is an indication that the program is not taking full advantage of the parallelization benefits of async/await" But it can still be performed. Since this functin is not speed dependent, await es-lint error is ignored.

Await inside For Loop

function getOrdinal(addressToChange) {
const streetNames = ['street', 'road', 'avenue'];
let address = addressToChange.toLowerCase().split(' ');
const number = address[address.length - 2];
const isNumber = !isNaN(number);
const isTeenNum = number % 100;
const isNotTeenNum = number % 10;
let ordinal = '';
if (!isNumber) {
f = {'red':'31m',
'green':'32m',
'yellow':'33m',
'blue':'34m',
'magenta':'35m',
'cyan':'36m',
'lightgray':'37m',
'darkgray':'90m',
'white':'97m'}