Skip to content

Instantly share code, notes, and snippets.

@davidair
davidair / animate_cube.py
Created February 25, 2024 01:47
Blender Script to continuously animate cubes of different heights
import bpy
import random
def my_animator(scene):
print("Frame change", scene.frame_current)
if scene.frame_current == 100:
bpy.ops.object.delete()
bpy.ops.mesh.primitive_cube_add(scale = (1, 1, 1 + random.uniform(0, 2.0)))
cube = bpy.context.active_object
@davidair
davidair / remove_net_8.patch
Created May 3, 2023 15:52
Fixing a build issue with slngen when .NET 8.0 is missing (based off faf0c43d8b6911881d7b8cf9bed7949636d00357 commit)
diff --git a/src/Microsoft.VisualStudio.SlnGen.Tool/Microsoft.VisualStudio.SlnGen.Tool.csproj b/src/Microsoft.VisualStudio.SlnGen.Tool/Microsoft.VisualStudio.SlnGen.Tool.csproj
index cde9cbd..eeb9cee 100644
--- a/src/Microsoft.VisualStudio.SlnGen.Tool/Microsoft.VisualStudio.SlnGen.Tool.csproj
+++ b/src/Microsoft.VisualStudio.SlnGen.Tool/Microsoft.VisualStudio.SlnGen.Tool.csproj
@@ -62,14 +62,6 @@
ReferenceOutputAssembly="false"
SkipGetTargetFrameworkProperties="true"
TargetFramework="net7.0" />
- <ProjectReference Include="..\Microsoft.VisualStudio.SlnGen\Microsoft.VisualStudio.SlnGen.csproj"
- SetTargetFramework="TargetFramework=net8.0"
#!/bin/bash
# Inspired by https://raspberrypi.stackexchange.com/a/28047/127204
MY_PATH="`dirname \"$0\"`"
LOG_PATH="/home/log/network.log"
now=$(date +"%m-%d %r")
# Which Interface do you want to check
@davidair
davidair / InstallShrinkPdf.cmd
Created April 18, 2022 16:06
Batch file that adds the "ShrinkPDF" context menu
@echo off
echo Installing the Shrink PDF shell extension
::Detecting gswin
where /q gswin64c.exe
IF ERRORLEVEL 1 (
echo Cannot find gswin64c.exe. Make sure you've installed Ghostscript.
echo You can install it with "choco install ghostscript".
@davidair
davidair / dyncode_td.py
Created April 11, 2021 05:03
Selenium Downloader for TD Canada Trust statements (technique described in https://airtdave.medium.com/exploring-web-automation-with-dynamic-code-f727b84fb7c0)
# Copyright 2021 Google LLC.
# SPDX-License-Identifier: Apache-2.0
if not ('main_window_handle' in vars() or 'main_window_handle' in globals()):
print('main_window_handle is not defined')
main_window_handle = driver.current_window_handle
driver.switch_to.window(main_window_handle)
frame = driver.find_element_by_css_selector('frame')
driver.switch_to.frame(frame)
@davidair
davidair / renamer.py
Created April 11, 2021 04:59
Filename renamer for TD Canada Trust statements to normalize timestamps
# Copyright 2021 Google LLC.
# SPDX-License-Identifier: Apache-2.0
import os
import pathlib
import re
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
pattern_td = r'(.+)([A-Za-z]{3})_(\d\d)-([A-Za-z]{3})_(\d\d)\_(\d\d\d\d).pdf'
pattern_loc = r'(.+)([A-Za-z]{3})_(\d\d)(_|-)(\d\d\d\d).pdf'
@davidair
davidair / dyncode_wiki.py
Last active March 8, 2021 23:53
Selenium-based harness that dynamically evaluates code to allow exploring web automation without re-running the driver
# Copyright 2021 Google LLC.
# SPDX-License-Identifier: Apache-2.0
search_input = driver.find_element_by_xpath("//input[@id='searchInput']")
search_input.clear()
search_input.send_keys('George Washington')
submit_button = driver.find_element_by_xpath("//button[@type='submit']")
submit_button.click()
@davidair
davidair / MainForm.cs
Last active August 12, 2022 06:39
Sample for self-registering desktop C# app that creates and reacts to toasts
/**
* Copyright 2020 Google LLC.
* SPDX-License-Identifier: MIT
*/
using Microsoft.Toolkit.Uwp.Notifications;
using System;
using System.Windows.Forms;
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
@davidair
davidair / Program.cs
Last active June 22, 2020 22:24
Example on how to save a shortcut with PKEY_AppUserModel_ID
/**
* Copyright 2020 Google LLC.
* SPDX-License-Identifier: MIT
*/
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;
using System;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
function fetchCall() {
const Http = new XMLHttpRequest();
const host = window.location.href.substring(0, window.location.href.indexOf(window.location.pathname));
const url = host + "/?file=1mb";
Http.open("GET", url);
Http.send();
Http.onreadystatechange = (e) => {
if (Http.readyState == XMLHttpRequest.DONE) {
document.getElementById("test_result").value = document.getElementById("test_result").value +
"\nReceived data, chunks remaining: " + _chunks;