Skip to content

Instantly share code, notes, and snippets.

View dcabines's full-sized avatar

David Cabiness dcabines

View GitHub Profile
foreach($file in Get-ChildItem -File) {
$folderName = $file.CreationTime.ToString('yyyy-MM-dd')
if (!(Test-Path -Path $folderName -PathType Container))
{
New-Item -Path $folderName -ItemType Directory
}
Move-Item -Path $file -Destination $folderName
}
Function Get-Files {
param ($path)
Get-ChildItem -Path $path -Recurse | ForEach-Object { @{ Name = $_.Name; Full = "$($_.Directory.FullName)\$($_.Name)"; } } | Sort-Object -Property {$_.Name.Replace('[','').Replace(']','').Replace('-','').Replace(' ','')}
}
$herePath = "H:\Path\To\Copy"
$therePath = $herePath -replace 'H:', 'T:'
$here = Get-Files($herePath)
$there = Get-Files($therePath)
$longestHere = $($here | ForEach-Object { $_.Name } | Measure-Object -Maximum -Property Length).Maximum + 5
@dcabines
dcabines / places.csv
Created December 4, 2023 23:31
ao: id,lng,lat
We can't make this file beautiful and searchable because it's too large.
51417,-123.25197,44.971416
55360,12.642866,42.546879
55585,-76.160188,39.982201
55536,-2.597938,51.450104
55165,28.942675,41.035439
51949,72.833672,18.94487
55445,-1.897225,52.474335
54432,-122.958577,38.504583
55606,-124.25909,40.587797
54815,12.395989,44.092597
@dcabines
dcabines / compress-folders.ps1
Created September 4, 2023 19:37
compress all folders inside current folder
foreach($folder in Get-ChildItem) {
if(Test-Path -PathType Leaf -Path "$folder.zip") {
Write-Host "Skipping $folder"
continue
}
Write-Host -NoNewline "Compressing $folder..."
Compress-7Zip -Path "$pwd\$folder" -ArchiveFileName "$folder.zip"
Write-Host "done"
}
@dcabines
dcabines / drip-ring.scad
Created November 2, 2022 13:34
For hydroponic irrigation
tube_radius = 4;
wall = 1.2;
ring_degree = 310;
ring_radius = 80;
ring_step = 10;
hole_min_radius = 0.6;
hole_max_radius = 1;
hole_diff_radius = hole_max_radius - hole_min_radius;
$originalsFolder = 'originals'
$resizedFolder = 'resized'
$reorganizedFolder = 'reorganized'
$originals = Get-ChildItem -Path $originalsFolder -Recurse -Include *.jpg
foreach ($original in $originals) {
$resized = Get-ChildItem -Path $resizedFolder -Recurse -Include $original.Name
$destination = ($resized.FullName).Replace($resizedFolder, $reorganizedFolder).Replace($resized.Name, "")
New-Item $destination -Type Directory
$fa = 1;
$fs = 1;
bell_height = 50;
bell_diameter = 10;
bell_wall = 1.2;
bell_foot_height = 10;
bell_foot_gap = 5;
snorkel_height = bell_height - 20;
const root = 'https://api.spacetraders.io';
// utils
const timeout = (seconds) => new Promise(resolve => setTimeout(resolve, seconds * 1000));
const sleeper = (seconds) => (x) => new Promise(resolve => setTimeout(() => resolve(x), seconds * 1000));
const userName = () => `user-${new Date().getTime()}-${Math.random()}`;
const querySeparator = (path) => path.indexOf('?') === -1 ? '?' : '&';
const get = (path) => fetch(`${root}${path}`).then(x => x.json()).then(saveState).then(saveArchive).then(sleeper(1));
const post = (path, body) => fetch(`${root}${path}`, postOptions(body)).then(x => x.json()).then(saveState).then(saveArchive).then(sleeper(1));
const put = (path, body) => fetch(`${root}${path}`, putOptions(body)).then(x => x.json()).then(saveState).then(saveArchive).then(sleeper(1));
union(){
translate([0, 0, 2])
union() {
translate([2,0,0]) cube([220,20,2]);
translate([222,0,0]) cube([2,20,18]);
cube([2,20,18]);
translate([0,0,16])
linear_extrude(
height = 2,
function element<e extends HTMLElementTagNameMap[keyof HTMLElementTagNameMap]>(
tag: keyof HTMLElementTagNameMap,
attributes: { [k in keyof HTMLParagraphElement]?: string; },
events: { [k in keyof HTMLElementEventMap]?: string; },
...children: HTMLElement[]
): e {
const element = document.createElement(tag) as e;
Object.keys(attributes).forEach(key => {
if (key === 'innerText') {