Skip to content

Instantly share code, notes, and snippets.

View kbaesler's full-sized avatar

Kyle Baesler kbaesler

View GitHub Profile
@kbaesler
kbaesler / ReSharper.v8.TypeMemberLayout.CSharp.xml
Last active December 28, 2015 08:29
A ReSharper Type Member Layout for C# that organizes the contents into logical regions.
<?xml version="1.0" encoding="utf-8" ?>
<!--
I. Overall
I.1 Each pattern can have <Match>....</Match> element. For the given type declaration, the pattern with the match, evaluated to 'true' with the largest weight, will be used
I.2 Each pattern consists of the sequence of <Entry>...</Entry> elements. Type member declarations are distributed between entries
I.3 If pattern has RemoveAllRegions="true" attribute, then all regions will be cleared prior to reordering. Otherwise, only auto-generated regions will be cleared
I.4 The contents of each entry is sorted by given keys (First key is primary, next key is secondary, etc). Then the declarations are grouped and en-regioned by given property
@kbaesler
kbaesler / GetAcronym.cs
Last active July 25, 2016 12:46
A C# method that will return the Acronym of input using LINQ
public string GetAcronym(string input)
{
string acronym = string.Join(string.Empty, input.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries).Select(s => s[0].ToString(CultureInfo.InvariantCulture)).ToArray());
return acronym
}
@kbaesler
kbaesler / SQL.Server.2008.Sequence.sql
Last active December 29, 2015 02:39
There is no concept of sequences in SQL Server 2008 R2, thus a combination of tables and stored procedures will be used to create the desired behavior.
-- Create the sequencing table that is used to hold the sequence values.
CREATE TABLE SQL_SERVER_SEQUENCE (
NAME VARCHAR(30) NOT NULL,
VALUE BIGINT DEFAULT 0 NOT NULL,
CONSTRAINT PK_SQL_SERVER_SEQUENCE PRIMARY KEY (NAME)
);
-- Create the stored procedure that is responsible for incrementing the sequence and return it.
ALTER PROCEDURE SQL_SERVER_SEQUENCE_NEXTVAL
@name VARCHAR(30)
@kbaesler
kbaesler / AutoCompleteTextBox.cs
Last active October 28, 2019 14:30
A simple version of an type-ahead (or auto complete) text box for WPF in C#.
using System;
using System.Collections.Generic;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
@kbaesler
kbaesler / pgrep.ps1
Created January 28, 2014 01:11
Recursively searches all text files in the current directory tree for a string with case sensitivity.
<#
Recursively searches all text files in the current directory tree for a string with case sensitivity.
Get-ChildItem -recurse -include *.txt | Select-String -CaseSensitive "SomeString"
pgrep SomeStringToSearch *.txt
#>
function pgrep { param([string]$search, [string]$inc) Get-ChildItem -recurse -include $inc | Select-String -CaseSensitive $search }
@kbaesler
kbaesler / associate_sde_stats.sql
Last active March 20, 2018 23:13
Oracle 11g: The post scripts that should be run after refreshing a geodatabase instance.
EXECUTE sys.utl_recomp.recomp_serial('SDE');
ASSOCIATE STATISTICS WITH PACKAGES sde.st_domain_operators, sde.st_relation_operators USING sde.st_domain_stats;
ASSOCIATE STATISTICS WITH INDEXTYPES sde.st_spatial_index USING sde.st_domain_stats;
ASSOCIATE STATISTICS WITH TYPES sde.st_geometry USING sde.st_domain_stats;
@kbaesler
kbaesler / split.py
Created June 10, 2014 21:59
Split the file into separate files based on the line count.
import os
import sys
# defines the main function for the script
def main():
# read the command line arguments for the file path.
if(len(sys.argv) >= 2):
file = sys.argv[1]
lines = int(sys.argv[2])
print 'Start: Split the %s file into files of %d lines'%(file, lines)
@kbaesler
kbaesler / Toggle.vb
Created September 4, 2014 22:29
VBA script to toggle on/off ArcFM Auto Updaters
' Reference Miner & Miner 9.x Geodatabase Library
Public Sub ToggleAU()
Dim pAU As IMMAutoUpdater
Set pAU = New MMAutoUpdater
If pAU.AutoUpdaterMode = mmAUMNoEvents Then
pAU.AutoUpdaterMode = mmAUMArcMap
Else
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeEditing/GenerateMemberBody/CopyXmlDocumentation/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantBaseQualifier/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantThisQualifier/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestUseVarKeywordEvident/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Reformat_002FCleanup/@EntryIndexedValue"></s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Reformat_002FCleanup/@EntryIndexRemov
@kbaesler
kbaesler / NonLockingReconcile.vb
Last active August 29, 2015 14:27
A VBA script that will reconcile the version without locking the parent.
' Reference Miner & Miner 9.x Geodatabase Library
Sub NonLockingReconcile()
On Error GoTo ErrorHandler
Dim conflictWindow As IConflictsWindow3
Dim editor As IEditor
Dim editorID As New UID
Dim conflictID As New UID