Skip to content

Instantly share code, notes, and snippets.

View tylergannon's full-sized avatar

Tyler Gannon tylergannon

  • Monte Rio, Ca
  • 18:57 (UTC -07:00)
View GitHub Profile
@tylergannon
tylergannon / $lib-server-mongoose-index.ts
Last active March 17, 2023 20:50
Avoiding OverwriteModelError while developing with mongoose and Svelte Kit (vite) dev server
/**
* @fileoverview Exports all models and mongoose instance
* @author @tylergannon
*
* Note the conditional creation of new models. This is to prevent
* conflict during development, between the HMR process repeating the
* same calls to mongoose.model(), which is not idempotent but throws
* an error if the model already exists.
*/
import type { Model } from 'mongoose';
@tylergannon
tylergannon / Instructions.md
Created February 16, 2023 14:49
Building Python C extensions on macOS

Setting up and building a Python C extension project on macOS

These instructions were developed for a project using vscode on macOS 13.0.1.

Install needed software

If you haven't already, you'll need an updated xcode command-line tools. Do this by running xcode-select --install or by going to https://developer.apple.com and downloading the XCode command line tools. I wound up with version 14.2.

cmake

@tylergannon
tylergannon / JvmTest.kt
Last active May 8, 2022 23:34
Kotlin multiplatform with compose tests
class ModelContainerHostTest {
@get:Rule
val composeTestRule = createComposeRule()
@Test fun firstTest() = runBlocking {
composeTestRule.setContent {
@Composable fun doAThing() = 1
doAThing() shouldBeExactly 2
}
@tylergannon
tylergannon / vim.md
Last active August 1, 2019 09:51
vim cheat sheet
@tylergannon
tylergannon / RBTree.rs
Last active July 31, 2023 20:48
Red Black Tree written in Rust
#![allow(dead_code)]
extern crate rand;
use std::cmp::Ord;
use std::cmp::Ordering;
use std::fmt::Debug;
use std::iter::Iterator;
use std::iter::IntoIterator;
use rand::Rng;
@tylergannon
tylergannon / GreaterThanBST.kt
Last active March 22, 2019 05:51
Kotlin Red Black Tree. For a programming challenge. Instead of a key-value store, it returns the number of items added, whose value is greater than than the given key.
class GreaterThanBST {
private var root : Node? = null
fun add(key : Int) {
root = put(root, key)
}
operator fun get(key : Int) : Int = get(root, key)
@tylergannon
tylergannon / Install-BaseComponents.ps1
Last active June 23, 2018 00:28
Install base components for Kubo
& {
$wid=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$prp=new-object System.Security.Principal.WindowsPrincipal($wid)
$adm=[System.Security.Principal.WindowsBuiltInRole]::Administrator
$IsAdmin=$prp.IsInRole($adm)
if (-not $IsAdmin)
{
Write-Host -ForegroundColor Yellow "This needs to be run as administrator."
Write-Host -ForegroundColor Yellow "Please open a new powershell as administrator, and try again."
exit 2
@tylergannon
tylergannon / Install-SingleApp.ps1
Last active June 22, 2018 23:19
Configure Git, Download Repository, Start Kubo inside of project.
# Command to run:
# $file = [System.IO.Path]::GetTempFileName(); (New-Object System.Net.WebClient).DownloadString('https://kubobuild.page.link/rniX') | Out-File -FilePath "${file}.ps1"; . "${file}.ps1"
& {
$wid=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$prp=new-object System.Security.Principal.WindowsPrincipal($wid)
$adm=[System.Security.Principal.WindowsBuiltInRole]::Administrator
$IsAdmin=$prp.IsInRole($adm)
if ($IsAdmin)
{
Write-Host -ForegroundColor Yellow "This should not be run as administrator."
@tylergannon
tylergannon / config.py
Last active November 5, 2017 13:17
restful SGE sample configuration file
"""
module: config
Note that this module defines three classes for three different applications.
You are free in your own configurations, to define separate files.
# The Restfful SGE app only listens to the RestfulSgeConfig class.
Loads the application configuration file, checking the following places:
@tylergannon
tylergannon / stylesheet.rb
Created October 17, 2016 04:11
Example PDF style declaration
module Stylesheet
extend ActiveSupport::Concern
include PdfStylesheet
PAGE_BREAK_RULES = [nil, 600, 200, 200, 100, 100].freeze
MARGIN_TOP_MM = 25
MARGIN_BOTTOM_MM = 30
MARGIN_LEFT_MM = 25
MARGIN_RIGHT_MM = 25