Skip to content

Instantly share code, notes, and snippets.

View marcusholmgren's full-sized avatar

Marcus Holmgren marcusholmgren

View GitHub Profile
@marcusholmgren
marcusholmgren / main.py
Created November 6, 2024 06:19
SqlAlchemy relations example
# sqlalchemy model with order and order_item tables
# sqlite3 database
# SQLAlchemy version 1.4
from sqlalchemy import create_engine, Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship, registry
mapper_registry = registry()
Base = mapper_registry.generate_base()
@marcusholmgren
marcusholmgren / guess_the_number_py
Created April 5, 2020 15:23
Simple game where you guess a random number between 1 - 25
#!/usr/bin/env python3
# Guess the Number
# 1. Ask the user how many times they would like to play
# 2. For every game, ask the player to select a random number between 1 - 25
# 3. Inform the player if the number is higher or lower
# 4. Build a loop statement that will iterate number of games and numbers picked
# 5. When user guess correct, tell them how many guesses it took
@marcusholmgren
marcusholmgren / logon_event_trigger.sql
Last active July 6, 2025 07:14
Trigger firing when users log on to the server
/**********************************************************************************************************************
* Name: trg_LogonAudit
* Type: Server-level DDL Trigger
* Description: Captures successful logon events for all users on the SQL Server instance and records them in
* a dedicated audit table.
*
* Author: Marcus Holmgren
* Created Date: 2025-07-07
*
* Dependencies: Requires a table to store the audit data.
@marcusholmgren
marcusholmgren / .gitconfig
Last active July 6, 2025 07:05
git configuration
[user]
name = <name>
email = <name>@gmail.com
# Consider adding a signing key for verified commits
# signingkey = <your_gpg_key>
[core]
# For macOS/Linux. Use `true` on Windows.
autocrlf = input
# Set your preferred editor
@marcusholmgren
marcusholmgren / Program.cs
Last active November 6, 2024 06:26
Ayende's modern version of the AbstractFactory
/*
* thanks to Ayende for idea, http://tekpub.com/shows/mct/1
*/
using System;
namespace AbstactFactory;
class Program
{
public static void Main()
@marcusholmgren
marcusholmgren / mstestcleanup.py
Created March 16, 2012 05:34
IronPython script that deletes files generated from MSTest results
__author__ = "Marcus Holmgren"
import sys
import clr
clr.AddReference('System')
from System import (Console, ConsoleColor, Exception)
from System.IO import (Directory, File, FileInfo, FileAttributes, SearchOption)
@marcusholmgren
marcusholmgren / CSharp-Mode.xshd
Created January 21, 2010 19:02
VibrantInk inspired syntax highligthing for C# in SharpDevelop
<?xml version="1.0" encoding="utf-8"?>
<!--This file was autogenerated by the #Develop highlighting editor.-->
<!--VibrantInk inspired syntax highligthing for C# in #Develop.-->
<SyntaxDefinition name="C#" extensions=".cs">
<Environment>
<Custom name="TypeReference" bold="false" italic="false" color="Pink" />
<Custom name="UnknownEntity" bold="false" italic="false" color="Yellow" />
<Default bold="false" italic="false" color="White" bgcolor="Black" />
<Selection bold="false" italic="false" color="White" bgcolor="#6897BB" />
<VRuler bold="false" italic="false" color="Pink" bgcolor="#E3E3E3" />