Skip to content

Instantly share code, notes, and snippets.

View trulysinclair's full-sized avatar
🏗️
Shaping my dreams into a digital form

Sinclair trulysinclair

🏗️
Shaping my dreams into a digital form
View GitHub Profile
@trulysinclair
trulysinclair / main.js
Last active December 4, 2024 18:29
Simple Spellcheck for Views
// A BrowserView can be used to embed additional web content into a BrowserWindow.
// It is like a child window, except that it is positioned relative to its owning
// window. It is meant to be an alternative to the webview tag.
//
// For more info, see:
// https://electronjs.org/docs/api/browser-view
// In the main process.
const { BrowserView, BrowserWindow, app, Menu, MenuItem } = require('electron/main')
@trulysinclair
trulysinclair / index.html
Created October 19, 2024 03:37
Experimental Shape Rendering
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
@trulysinclair
trulysinclair / index.html
Last active October 18, 2024 02:23
WebContents lifecycle (window and view)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
@trulysinclair
trulysinclair / index.html
Last active September 25, 2024 23:10
Bind BrowserView to ResizeObserver output
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<!-- <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'"> -->
<title>Hello World!</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
@trulysinclair
trulysinclair / index.html
Last active September 9, 2024 19:29
Super simple drag and drop
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
<link rel="stylesheet" href="style.css" />
</head>
@trulysinclair
trulysinclair / electron.vite.config.ts
Created August 30, 2024 20:09
An electron-vite config which covers: multi-window, TanStack Router, generating a product.json, and using Prisma for an internal SQLite3 database. It's not clean, but it works.
import typescript from "@rollup/plugin-typescript";
import {TanStackRouterVite} from "@tanstack/router-plugin/vite";
import react from "@vitejs/plugin-react";
import {defineConfig, externalizeDepsPlugin} from "electron-vite";
import {existsSync} from "fs";
import {mkdir, rm, writeFile} from "fs/promises";
import {copyFile} from "node:fs/promises";
import {resolve} from "path";
import {IProduct} from "./src/platform/product/common/product-service.interface.js";
@trulysinclair
trulysinclair / from_xml.ts
Last active July 10, 2024 22:45
Convert xml2js output into badgerfish convention
import { toBadgerfish } from '#util/badgerfish/to_badgerfish'
import { JsonObject } from '#util/badgerfish/types'
import { Parser } from 'xml2js'
/**
* Convert XML to Badgerfish JSON convention
* @param {string} xml
* @returns {Promise<JsonObject>}
*/
export async function fromXml(xml: string) {
@trulysinclair
trulysinclair / transfer.ps1
Last active August 2, 2024 19:48
transfer-bulk-issues.ps1
$issues = gh issue list -s all -L 500 --json number | ConvertFrom-Json
foreach ($issue in $issues) {
$issueNumber = $issue.number
gh issue transfer $issueNumber https://github.com/<your-org>/<your-repo>
}
@trulysinclair
trulysinclair / monorepo.dprint.json
Last active June 28, 2023 18:30
Dprint Configuration
{
"typescript": {
"ifStatement.useBraces": "preferNone",
"newLineKind": "lf",
"preferHanging": true,
"singleBodyPosition": "nextLine",
"useBraces": "preferNone",
"bracePosition": "sameLineUnlessHanging",
"arrowFunction.useParentheses": "force",
"arguments.preferHanging": "always",
@trulysinclair
trulysinclair / autotyper-1.0
Created June 25, 2023 03:43
Simple cheat for typing tests.
// Get the parent element by its class names
const parentElement = document.querySelector('.css-1rw37je.eu4oa1w0');
// Check if the parent element exists
if (parentElement) {
// Get all the child spans of the parent element
const childSpans = parentElement.querySelectorAll('span');
// Create an array to store the words
const wordsArray = [];