Skip to content

Instantly share code, notes, and snippets.

@iandesj
iandesj / index.ts
Created October 8, 2024 15:54
Extension example for cell execution events
import {
JupyterFrontEnd,
JupyterFrontEndPlugin
} from '@jupyterlab/application';
import { NotebookActions } from '@jupyterlab/notebook';
/**
* Initialization data for the constellate_lab_usage extension.
*/
const plugin: JupyterFrontEndPlugin<void> = {
@iandesj
iandesj / new.sh
Created June 12, 2024 04:00
lazy way to spin up a new code project with bash fn
new() {
# Create a new project
# Usage: new project-name
# Options:
# --python: Initialize a new Python project
# --node: Initialize a new Node project
# --nuxt: Initialize a new Nuxt project
# --csharp: Initialize a new C# dotnet core MVC project
# --override: Override existing project
usage() {
@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);