Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Rob Reynolds ferventcoder

🎯
Focusing
View GitHub Profile
View EnumerationExtensions.cs
public static class EnumerationExtensions
{
public static IEnumerable<SelectListItem> GetEnumerationItems(this Enum enumeration)
{
var listItems = Enum
.GetValues(enumeration.GetType())
.OfType<Enum>()
.Select(e =>
new SelectListItem()
{
View IsUACEnabled.cmd
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA
@ferventcoder
ferventcoder / get-input.ps1
Last active May 14, 2022
Testing PowerShell Fuzzy Parameter matching
View get-input.ps1
function Get-Input {
[CmdletBinding()]
param (
[string]$abcdef = 'exe',
[parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments
)
$invocaton = $MyInvocation
$argumentsPassed = ''
foreach ($param in $PSBoundParameters.GetEnumerator()) {
$argumentsPassed += "-$($param.Key) '$($param.Value -Join ' ')' "
@ferventcoder
ferventcoder / UserAdd.ps1
Created Mar 26, 2014
Adding a user to a group and managing Home Directory
View UserAdd.ps1
param (
[parameter(Position=0)]
[alias("user")][string]$userName,
[alias("group")][string]$groupName=$null,
[alias("home")][string]$homeDirectory=$null
)
# there are some much simpler ways to do this with the Active-Directory Module
# like Get-ADUser, Set-ADUser, etc but it is not installed on Win2008 (non-R2)
# and below so we want to prefer what works natively for all Windows machines
@ferventcoder
ferventcoder / CustomService.cs
Created Aug 29, 2011
Debugging Windows Services
View CustomService.cs
public partial class CustomService : ServiceBase
{
protected override void OnStop()
{
//normal shutdown code here
}
protected override void OnStart(string[] args)
{
//normal startup code here
@ferventcoder
ferventcoder / RemoveListItem.cs
Created Sep 24, 2012
How to Remove Items from A List ?
View RemoveListItem.cs
foreach (var item in items.ToList())
{
items.Remove(item);
}
View GetSwap.VB
Public Function GetSwapNumber(ByVal session As ISession, ByVal instrument As Instrument) As String
Dim swapNumber As String = String.Empty
Dim crit As DetachedCriteria = DeCrit.UniqueSwapAssignmentByInstrumentId(instrument)
Dim swapAssignments As IList(Of SwapAssignment)
Dim newSession As ISession = session.GetSession(EntityMode.Poco)
swapAssignments = crit.GetExecutableCriteria(newSession).List(Of SwapAssignment)()
For Each swap As SwapAssignment In swapAssignments
If (swap.Swap IsNot Nothing) Then
View UACHandling.ps1
$uacRegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
$uacRegValue = "EnableLUA"
$uacEnabled = $false
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx
$osVersion = [Environment]::OSVersion.Version
if ($osVersion -ge [Version]'6.0')
{
$uacRegSetting = Get-ItemProperty -Path $uacRegPath
try {
@ferventcoder
ferventcoder / Where.ps1
Created Apr 4, 2012
Somebody's where.exe implementation as powershell ;)
View Where.ps1
$exe = 'git';
if($exe.EndsWith('.exe') -or $exe.EndsWith('.bat')) { $exe = $exe.Substring(0, $exe.Length - 4)}; (ls env:\path).Value.split(';') | %{ if( test-path "$_\$exe.exe" ) { ls "$_\$exe.exe" }; if( test-path "$_\$exe.bat" ) { ls "$_\$exe.bat" }; } | %{ if($_.FullName.EndsWith('.exe') -or $_.FullName.EndsWith('.bat')) { $_.FullName } }
@ferventcoder
ferventcoder / 1Registration.cs
Created Jul 17, 2012
WebBackgrounder - IoC improvements
View 1Registration.cs
Bind<IJob>().ToMethod(context => new SyncWithMeetingsJob(context.Kernel, interval: TimeSpan.FromMinutes(Config.GetConfigurationSettings().MeetingsMinutesBetweenUpdates), timeout: TimeSpan.FromMinutes(20))).InSingletonScope();