Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Rob Reynolds ferventcoder

🎯
Focusing
View GitHub Profile
View chocolateyInstall.ps1
#NOTE: Please remove any commented lines to tidy up prior to releasing the package, including this one
# REMOVE ANYTHING BELOW THAT IS NOT NEEDED
$ErrorActionPreference = 'Stop'; # stop on all errors
$packageName= '[[PackageName]]' # arbitrary name for the package, used in messages
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$url = '[[Url]]' # download url
$url64 = '[[Url64]]' # 64bit URL here or remove - if installer is both, use $url
$packageArgs = @{
packageName = $packageName
@ferventcoder
ferventcoder / disablechromeautoupdate.ps1
Created February 9, 2018 12:58
Disable Google Chrome Automatic Update Policy
View disablechromeautoupdate.ps1
$googlePoliciesKey = 'HKLM:\Software\Policies\Google'
if (!(Test-Path $googlePoliciesKey)) {
New-Item -Path $googlePoliciesKey -Force | Out-Null
}
New-ItemProperty $googlePoliciesKey -Name 'UpdateDefault' -Value 0 -PropertyType DWORD -Force | Out-Null
@ferventcoder
ferventcoder / NonAdmin.cmd
Last active February 6, 2023 19:13
Installing Software as a Non-Administrator Using Chocolatey
View NonAdmin.cmd
:: Pick one of these two files (cmd or ps1)
:: Set directory for installation - Chocolatey does not lock
:: down the directory if not the default
SET INSTALLDIR=c:\ProgramData\chocoportable
setx ChocolateyInstall %INSTALLDIR%
:: All install options - offline, proxy, etc at
:: https://chocolatey.org/install
@powershell -NoProfile -ExecutionPolicy Bypass -Command "(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))) >$null 2>&1" && SET PATH="%PATH%;%INSTALLDIR%\bin"
@ferventcoder
ferventcoder / EnumerationExtensions.cs
Created April 4, 2012 19:04
MVC Html DropDownListHelper
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()
{
@ferventcoder
ferventcoder / IsUACEnabled.cmd
Created December 17, 2013 16:06
UAC enabled?
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 02:47
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 March 26, 2014 17:08
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 August 29, 2011 19:29
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 September 24, 2012 22:29
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