Skip to content

Instantly share code, notes, and snippets.

View bradmartin333's full-sized avatar

Brad Martin bradmartin333

View GitHub Profile
function main(workbook: ExcelScript.Workbook): string {
// Get all the worksheets in the workbook.
let sheets = workbook.getWorksheets();
// Don't treat these strings as dates
let notDates = ['NA', '', 'ETA DATE'];
// Compare to yesterday
let today = new Date(Date.now()).getTime() - (24 * 60 * 60 * 1000);
console.log(today.toString());
@bradmartin333
bradmartin333 / power_supply_timer.ino
Created January 16, 2022 14:30
fade colors with neopixel
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 9
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);
const uint32_t Green = Adafruit_NeoPixel::Color(00, 255, 0);
const uint32_t Red = Adafruit_NeoPixel::Color(255, 0, 0);
void setup() {
@bradmartin333
bradmartin333 / set_all_layers_mode.scm
Created January 3, 2022 22:57
Set all GIMP layers to same mode
(define (script-fu-set-layers-mode
image
layer
mode
)
(let*
(
(width (car (gimp-image-width image)))
(height (car (gimp-image-height image)))
public static string SaveFile(string title, string filter)
{
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
{
saveFileDialog.RestoreDirectory = true;
saveFileDialog.Title = title;
saveFileDialog.Filter = filter;
if (saveFileDialog.ShowDialog() == DialogResult.OK)
return saveFileDialog.FileName;
}
@bradmartin333
bradmartin333 / NiceScatterXYZ.py
Created September 14, 2021 18:18
NiceScatterXYZ
import sys
import csv
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from scipy.linalg import lstsq
# Read CSV
csvFileName = sys.argv[1]
csvData = []
public static void OpenWithDefaultProgram(string path)
{
using (Process fileopener = new Process())
{
fileopener.StartInfo.FileName = "explorer";
fileopener.StartInfo.Arguments = "\"" + path + "\"";
fileopener.Start();
}
}
@bradmartin333
bradmartin333 / RotateZoomClick.cs
Created August 16, 2021 16:37
Get click pos on rotated image in PictureBox with zoom type view
public static Point ZoomMousePos(Point click)
{
PictureBox pbx = Components.Vision;
float BackgroundImageAspect = pbx.BackgroundImage.Width / (float)pbx.BackgroundImage.Height;
float controlAspect = pbx.Width / (float)pbx.Height;
PointF pos = new PointF(click.X, click.Y);
if (BackgroundImageAspect > controlAspect)
{
float ratioWidth = pbx.BackgroundImage.Width / (float)pbx.Width;
pos.X *= ratioWidth;
@bradmartin333
bradmartin333 / PiePrep.cs
Last active August 5, 2021 14:27
Generate linear scan coordinates for a circular area
using System;
using System.Collections.Generic;
using System.Drawing;
namespace PiePrep
{
class Program
{
static void Main(string[] args)
{
using System;
using System.Drawing;
using System.IO;
namespace XYZmanipulator
{
class Program
{
static void Main()
{
from PIL import Image, ImageFont, ImageDraw, ExifTags
import pathlib
import os
imageExtensions = ['.png', '.jpg', '.jpeg', '.tiff', '.bmp', '.gif']
basewidth = 600 # Adjust output file size
# Make output dir
if not os.path.exists('watermark'):
os.makedirs('watermark')