Skip to content

Instantly share code, notes, and snippets.

View mjdescy's full-sized avatar

Michael Descy mjdescy

View GitHub Profile
@mjdescy
mjdescy / MakeActiveChartOverlapRange.bas
Created April 9, 2020 17:41
Make active Excel chart overlap a range completely
Option Explicit
Public Sub SetActiveChartToCompletelyCoverARange()
Call ResizeAndRepositionChart( _
Chart:=ActiveChart, _
Range:=AskUserToInputARange())
End Sub
Private Sub ResizeAndRepositionChart(ByRef Chart As Excel.Chart, ByRef Range As Excel.Range)
If Chart Is Nothing Then
@mjdescy
mjdescy / SizeActiveChart.mod
Last active April 9, 2020 14:41
Excel macro for setting the selected chart to a default size
Option Explicit
Const DefaultChartHeightInInches As Double = 4#
Const DefaultChartWidthInInches As Double = 8.3
Public Sub SetActiveChartToStandardSize()
If ActiveChart Is Nothing Then
Exit Sub
End If
@mjdescy
mjdescy / RowHeightAdjustments.mod
Created April 9, 2020 00:20
Adjust Row Height in Excel
Option Explicit
Const DefaultRowHeight As Double = 14.5
Public Sub IncreaseRowHeightByOneLine()
Call SafelyAdjustRowHeightForAllRowsInRange(Range:=Selection, RowHeightAdjustment:=DefaultRowHeight)
End Sub
Public Sub DecreaseRowHeightByOneLine()
Call SafelyAdjustRowHeightForAllRowsInRange(Range:=Selection, RowHeightAdjustment:=-DefaultRowHeight)
@mjdescy
mjdescy / SemanticVersionNumber.swift
Created June 6, 2018 17:42
Semantic Version Number struct (Swift 4.1)
import Foundation
public struct SemanticVersionNumber: Equatable {
public let major: Int
public let minor: Int
public let patch: Int
public init?(version: String) {
let components = version.split(separator: ".")
guard components.count == 3 else { return nil }
@mjdescy
mjdescy / DAOTemporaryTableController.cls
Created May 30, 2018 15:18
Microsoft Access VBA class to create a temporary table and automatically delete it upon release
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "DAOTemporaryTableController"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Compare Database
@mjdescy
mjdescy / DAOQueryRunner.cls
Created May 30, 2018 15:10
Microsoft Access VBA class to run queries via DAO
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "DAOQueryRunner"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Compare Database
@mjdescy
mjdescy / LoggedInUserName.bas
Last active May 30, 2018 15:42
VBA Module to Get Logged In User Name from Windows API
Attribute VB_Name = "LoggedInUserName"
Option Explicit
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function GetLoggedInUserName() As String
Dim MaxBufferLength As Long
MaxBufferLength = 255
@mjdescy
mjdescy / pia.sh
Last active August 29, 2015 14:20 — forked from dapperfu/pia.sh
#!/bin/tcsh
# Grab user information.
echo "PrivateInternetAccess OpenVPN Setup:"
echo " https://www.privateinternetaccess.com/pages/client-control-panel"
echo " -> PPTP/L2TP/SOCKS Username and Password"
echo -n "User: "
set user = $<
echo -n "Pass: "
set pass = $<
@mjdescy
mjdescy / FileNameReplace
Created May 7, 2014 17:59
Windows PowerShell Batch Rename Files
dir | Rename-Item -NewName { $_.name -replace "OldText", "ReplacementText" }
@mjdescy
mjdescy / Microsoft Access Drop Primary Key Constraint SQL
Created April 14, 2014 20:55
Microsoft Access Drop Primary Key Constraint SQL
ALTER TABLE TableName DROP CONSTRAINT PrimaryKey;