Skip to content

Instantly share code, notes, and snippets.

@iandesj
iandesj / trivy_report.sh
Created September 28, 2023 14:22
Build && Scan
#! /bin/bash
# Build and scan with trivy
IMAGE_TAG=$1
DOCKERFILE="${2:-Dockerfile}"
docker build -t $IMAGE_TAG . -f $DOCKERFILE \
&& trivy image --severity HIGH,CRITICAL $IMAGE_TAG --report summary --scanners vuln
@iandesj
iandesj / .gitconfig
Created August 18, 2022 20:16
git push-new
# alias for setting upstream on origin for current branch
[alias]
push-new = ! git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)
@iandesj
iandesj / parallel_hack_lol.sh
Created November 8, 2021 20:29
Parallel Hack LOL
#!/bin/bash
N=10
for i in $(seq 1 $N); do echo ./makemeparallel.py $i &; done
echo 'VOILA!'
@iandesj
iandesj / md5_hash_dir.sh
Created July 9, 2021 13:49
Get MD5 Hash of Directory Contents
# replace md5sum with md5 on a mac
# for javascript/node codebase
find -s client -not -path "*/node_modules/*" -type f -exec md5sum {} \; | md5sum
# python codebase with venv/
find -s backend -not -path "*/venv/*" -type f -exec md5sum {} \; | md5sum
@iandesj
iandesj / exclusiveArrayFiltering.js
Created November 6, 2020 19:37
Exclude array items from another
const allClasses = [
{
id: 1,
name: 'Yoga 100',
enrolled: 10,
maxCapacity: 11,
},
{
id: 2,
name: 'Yoga 200',
@iandesj
iandesj / enum.js
Created November 27, 2019 16:39
Example of an Enum-esque construct in JS
const enumValue = (name) => Object.freeze({toString: () => name});
const Colors = Object.freeze({
RED: enumValue("Colors.RED"),
BLUE: enumValue("Colors.BLUE"),
GREEN: enumValue("Colors.GREEN")
});
@iandesj
iandesj / lcm.py
Last active October 23, 2019 03:13
Least common multiple finder i wrote in python... cuz who doesn't need a good LCM finder from time to time, amirite?
def lcm(nums):
greatest = max(nums)
while True:
all_good = all(
list(map(lambda x: greatest % x == 0, nums))
)
if all_good:
return greatest
greatest += 1
@iandesj
iandesj / object_destructuring_examples.js
Last active November 14, 2019 14:18
Examples of object destructuring vs direct object key-value access
const taxPayer = {
firstName: 'Ian', lastName: 'DesJardins',
ssn: '123-45-6789', pastDue: true,
};
console.log('Object destructuring example');
// destructure the taxPayer object into new variables
const { firstName, lastName, ssn, pastDue } = taxPayer;
console.log('firstName =', firstName);
@iandesj
iandesj / array_destructuring_examples.js
Last active November 14, 2019 14:13
Examples of array destructuring vs array index accessing
const taxPayer = [ 'Ian', 'DesJardins', '123-45-6789', true ];
console.log('Array destructuring example');
// destructure the taxPayer array into new variables
const [ firstName, lastName, ssn, pastDue ] = taxPayer;
console.log('firstName =', firstName);
console.log('lastName =', lastName);
console.log('ssn =', ssn);
console.log('pastDue =', pastDue, '\n');
@iandesj
iandesj / array_from_examples.js
Last active November 14, 2019 13:59
Examples of Array.from() vs for loop
const year = 2019;
const month = 10; // november, zero-indexed
const startDay = 14;
console.log('Array.from() example');
const dateList = Array.from({length:7}, (val, idx) => {
return new Date(year, month, startDay + idx);
});
console.log('dateList = ', dateList, '\n');