Skip to content

Instantly share code, notes, and snippets.

View radleta's full-sized avatar

Richard Adleta radleta

View GitHub Profile
@radleta
radleta / ProgramAsync.cs
Last active November 25, 2019 18:03
C# Async vs Sync Examples
using System;
using System.Threading.Tasks;
using System.Threading;
using System.IO;
namespace AsyncTechTalk
{
class ProgramAsync
{
static int number = 0;
@radleta
radleta / git-resolve-rejects.ps1
Created November 1, 2019 12:31
Git: Iterate through all the *.rej files and resolve them using Notepad++
$npp = "C:\Program Files\Notepad++\notepad++.exe"
# env to redirect git output
$env:GIT_REDIRECT_STDERR = '2>&1'
git status --short | ForEach-Object {
# break the line into its parts
$line = $_.Trim()
$separator = $line.IndexOf(" ")
@radleta
radleta / download-chrome.ps1
Last active December 2, 2019 21:31
Download Latest Version of Chrome via Powershell
Invoke-WebRequest 'https://dl.google.com/chrome/install/latest/chrome_installer.exe' -Outfile chrome_installer.exe
@radleta
radleta / apply-patches.ps1
Created October 25, 2019 14:15
Git: Apply all the *.patch files to a git repo stopping when conflict exists
# -src is the source dirtory where the *.patch files exist
# -archive is the directory to move the *.patch files to once they have been applied
param([string]$src="", [string]$archive="")
# env to redirect git output
$env:GIT_REDIRECT_STDERR = '2>&1'
# check to ensure -src is provided
if ($src -eq "")
{
@radleta
radleta / how-to-win-rsync-from-cmd.md
Last active March 14, 2025 13:39
Step-by-step how to use rsync with git bash from Windows command prompt

Note: This works all except for the shell script part. Need to figure that out. You can do it interactively just not from the command prompt.

  1. Install Git
  2. Install Git Bash via Git Tortoise install
  3. Added HOME=/c/Users/$USERNAME to C:\Program Files\Git\etc\profile
  4. See https://stackoverflow.com/questions/32232978/change-the-location-of-the-directory-in-a-windows-install-of-git-bash
  5. Download rsync.exe from https://repo.msys2.org/msys/x86_64/rsync-3.2.3-2-x86_64.pkg.tar.zst use 7-zip to decompress
  6. See https://blog.tiger-workshop.com/add-rsync-to-git-bash-for-windows/
  7. Put rsync.exe into C:\Program Files\Git\usr\bin
  8. Open Git Bash and create a key file using ssh-keygen
@radleta
radleta / Nearest5Minutes.sql
Created March 22, 2019 14:29
Round DateTime to nearest 5 minutes. Useful when grouping by DateTime to round to the nearest 5 minutes.
SELECT dateadd(minute, datediff(minute, '1900-01-01', dateadd(second, 150, GETDATE()))/5*5, 0)
@radleta
radleta / count_props.js
Last active October 23, 2018 16:11
Count Properties of Value Obj (Couchbase Reduce Function)
function (keys, values, rereduce)
{
var reduced = {};
for (var v in values) {
var val = values[v];
for (var k in val) {
if (val[k]) {
if (rereduce) {
reduced[k] = (reduced[k] || 0) + (val[k] || 0);
} else {
@radleta
radleta / check_mssql
Last active September 24, 2020 17:38
Nagios Plugin check_mssql
#!/usr/bin/php
<?php
############################################################################
#
# check_mssql - Checks various aspect of MSSQL servers
#
# Copyright (c) 2008 Gary Danko <[email protected]>
# Version 0.7.1 Copyright (c) 2013 Nagios Enterprises, LLC (Nicholas Scott <[email protected]>)
# Version 0.8.0 - 0.8.4 Copyright (c) 2017 Nagios Enterprises, LLC (Jake Omann <[email protected]>)
@radleta
radleta / tcp_host_counts.sh
Last active September 14, 2018 06:44
Get the host names of the machines connected via TCP in Bash
netstat | grep ESTABLISHED | sed -E 's/tcp[0-6]*\s+[0-9]+\s+[0-9]+\s+[a-z0-9]+(\.[0-9a-z]*)*:([0-9a-z]+)\s+//' | sed -E 's/(\.[a-z]*)*:[-a-z0-9]+\s+ESTABLISHED//' | sort | uniq -c
@radleta
radleta / Get-NetFrameworkVersion.ps1
Created March 28, 2017 20:38
PowerShell to Get the .NET Framework Versions Installed on a Remote Machine
<#
Script Name : Get-NetFrameworkVersion.ps1
Description : This script reports the various .NET Framework versions installed on the local or a remote computer.
Author : Martin Schvartzman
Last Update : Aug-2016
Keywords : NETFX, Registry
Reference : https://msdn.microsoft.com/en-us/library/hh925568
#>
param($ComputerName = $env:COMPUTERNAME)
#param($ComputerName = 'remotemachinename')