Skip to content

Instantly share code, notes, and snippets.

View brandonmartinez's full-sized avatar

Brandon Martinez brandonmartinez

View GitHub Profile
@brandonmartinez
brandonmartinez / gist:8336110
Created January 9, 2014 15:39
A sample structure map configuration. Requires the StructureMap nuget package (obviously). Can paste into a console app to run and test the demo.
using System;
using System.Collections.Generic;
using System.Linq;
using StructureMap;
using StructureMap.Configuration.DSL;
namespace StructureMapExample
{
/// <summary>
/// A registry; I configure these one per "area" of my application. If it's a
@brandonmartinez
brandonmartinez / Email Regex
Created September 19, 2014 14:34
A basic regex for email validation
[A-z0-9!#$%&'*+/=?^_`{|}~-]+[A-z0-9!#$%&'*+/=?.^_`{|}~-]*(?:-/.[A-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-z0-9](?:[A-z0-9-]*[A-z0-9])?\.)+[A-z0-9](?:[A-z0-9-]*[A-z0-9])?
@brandonmartinez
brandonmartinez / vncboot
Created February 13, 2015 19:14
Raspberry Pi VNC Boot Script
# First configure the user you want to run this under - this will generally be pi, unless you've created your own users
export USER='pi'
eval cd ~$USER
# Check the state of the command - this'll either be start or stop
case "$1" in
start)
# if it's start, then start vncserver using the details below
su $USER -c '/usr/bin/vncserver :1 -geometry 1280x800 -depth 16 -pixelformat rgb565'
#Requires -Version 3.0
param($websiteNames, $jobname, $jobtype, $packOutput, $slotName = "")
$VerbosePreference = "continue"
$ErrorActionPreference = "continue"
# Helper Functions (based on or from https://github.com/aspnet/vsweb-publish/blob/master/publish-module.psm1)
function Get-MSDeploy{
[cmdletbinding()]
@brandonmartinez
brandonmartinez / ExpressionExtensions.cs
Created October 5, 2018 20:50
Wrote some code for a project, but ended up scrapping it since we refactored and simplified the calling code. Just wanted to keep the code in case I need to mess with expressions for property getters and setters again.
using System;
using System.Linq.Expressions;
using System.Reflection;
namespace MyProject.Services.SystemExtensions
{
public static class ExpressionExtensions
{
/// <summary>
/// Compiles a getter Func from an expression to access a property
@brandonmartinez
brandonmartinez / ang.ps1
Created May 3, 2021 20:32
Azure Name Generator
#!/usr/bin/env pwsh
param (
[Parameter(Position = 1, mandatory = $true)]
[string]$resourceType,
[Parameter(Position = 2, mandatory = $true)]
[string]$workload,
[Parameter(Position = 3, mandatory = $true)]
[string]$environment,
[Parameter(Position = 4, mandatory = $true)]
@brandonmartinez
brandonmartinez / portal.azure.com.hideuserinformation.user.js
Last active March 4, 2022 19:51
Tampermonkey | Azure Portal | Hide User Information
// ==UserScript==
// @name Azure Portal | Hide User Information
// @version 0.1
// @description Hides the signed in user name and avatar in the Azure portal.
// @author Brandon Martinez
// @grant none
// @include https://portal.azure.com/*
// @include https://ms.portal.azure.com/*
// ==/UserScript==
@brandonmartinez
brandonmartinez / StabilizeVideosInFolder.sh
Created July 30, 2022 05:57
Search a folder for MP4 files and stabilize them with ffmpeg and vid.stab.
#!/bin/sh
####################################################################################
# This script searches the passed in directory for video files (*.mp4, *.mov, *.m4v)
# and stabilizes them using ffmpeg and libvidstab (required before running). It will
# create a transform file (*.trf), then use the information to create a new video
# with a `-stabilized` suffix.
#
# Based on https://www.paulirish.com/2021/video-stabilization-with-ffmpeg-and-vidstab/
####################################################################################
@brandonmartinez
brandonmartinez / printer-Ender3S1Plus.cfg
Last active January 7, 2024 12:00
My klipper printer.cfg for the Ender 3 S1 Plus
# Based on: https://github.com/Klipper3d/klipper/blob/master/config/printer-creality-ender3-s1plus-2022.cfg
# This file contains pin mappings for the stock 2022 Creality Ender 3
# S1 Plus. To use this config check the STM32 Chip on the Mainboard,
# during "make menuconfig" select accordingly either the
# STM32F103 with "28KiB bootloader" or the STM32F401 with
# "64KiB bootloader" and serial (on USART1 PA10/PA9) for both.
# For a direct serial connection, in "make menuconfig" select
# "Enable extra low-level configuration options" and Serial
# (on USART2 PA3/PA2), which is on the 10 pin IDC cable used
@brandonmartinez
brandonmartinez / CreatedAndRecordDateCleanup.sh
Created November 19, 2023 19:38
A script that will take videos named in the YYYY-MM-DD-HH-mm-ss* format and use that to update the file created date time and EXIF created date times. Meant to run on macOS (due to `touch` and `stat` differences from linux).
#!/bin/zsh
DEBUG=${DEBUG:-false}
fullpath=$1
log_header() {
RED=$(tput setaf 1)
WHITE=$(tput setaf 7)
RESET=$(tput sgr0)