Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Descy mjdescy

View GitHub Profile
@mjdescy
mjdescy / MakeActiveChartOverlapRange.bas
Created Apr 9, 2020
Make active Excel chart overlap a range completely
View MakeActiveChartOverlapRange.bas
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 Apr 9, 2020
Excel macro for setting the selected chart to a default size
View SizeActiveChart.mod
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 Apr 9, 2020
Adjust Row Height in Excel
View RowHeightAdjustments.mod
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 Jun 6, 2018
Semantic Version Number struct (Swift 4.1)
View SemanticVersionNumber.swift
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
Microsoft Access VBA class to create a temporary table and automatically delete it upon release
View DAOTemporaryTableController.cls
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
Microsoft Access VBA class to run queries via DAO
View DAOQueryRunner.cls
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
VBA Module to Get Logged In User Name from Windows API
View LoggedInUserName.bas
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
View 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
Windows PowerShell Batch Rename Files
View FileNameReplace
dir | Rename-Item -NewName { $_.name -replace "OldText", "ReplacementText" }
@mjdescy
mjdescy / Microsoft Access Drop Primary Key Constraint SQL
Created Apr 14, 2014
Microsoft Access Drop Primary Key Constraint SQL
View Microsoft Access Drop Primary Key Constraint SQL
ALTER TABLE TableName DROP CONSTRAINT PrimaryKey;