Skip to content

Instantly share code, notes, and snippets.

View jpogran's full-sized avatar
📙
Intersection of prose and technology

James Pogran jpogran

📙
Intersection of prose and technology
View GitHub Profile
@mgraeber-rc
mgraeber-rc / powershell_structured_query.xml
Created March 16, 2021 17:33
Example custom event view I used to display only relevant PowerShell logs for a demo
<QueryList>
<Query Id="0" Path="Security">
<Select Path="Security">
*[System[(EventID='4688')]]
and
*[EventData[Data[@Name='NewProcessName']='C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe']]
</Select>
<Select Path="Microsoft-Windows-PowerShell/Operational">
*[System[(EventID='4104')]]
and
@LawrenceHwang
LawrenceHwang / Pre-Meeting-Check.ps1
Created July 15, 2020 17:59
Pre-meeting system health check using PowerShell's Pester 5.
Describe 'Pre-meeting Check List' { # These are a Pester 5 compliant tests.
Context 'Device Check' {
It 'Device should be present and have OK status: [<deviceName>]' -TestCases @(
@{deviceName = 'Blue Snowball' }
@{deviceName = '*TrackBall Mouse' }
@{deviceName = 'Microphone (Blue Snowball)' }
@{deviceName = 'Canon EOS 6D Mark II' }
) {
$device = (Get-PnpDevice -FriendlyName $deviceName -Status 'OK' -PresentOnly -ErrorAction SilentlyContinue)
$device.count | Should -BeGreaterOrEqual 1
@mislav
mislav / gh-rename-master
Last active April 24, 2022 10:02
Rename the default branch of a repository using GitHub CLI https://github.com/cli/cli/releases/tag/v0.10.0
#!/bin/bash
# Usage: gh-rename-master <newbranch> [<remote>]
#
# Renames the "master" branch of the current repository both locally and on GitHub.
#
# dependencies: GitHub CLI v0.10
set -e
newbranch="${1?}"
remote="${2:-origin}"
@SteveL-MSFT
SteveL-MSFT / profile.ps1
Last active August 26, 2024 04:53
PowerShell Prompt
#Requires -Version 7
# Version 1.2.13
# check if newer version
$gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e"
$latestVersionFile = [System.IO.Path]::Combine("$HOME",'.latest_profile_version')
$versionRegEx = "# Version (?<version>\d+\.\d+\.\d+)"
if ([System.IO.File]::Exists($latestVersionFile)) {
@davidfowl
davidfowl / dotnetlayout.md
Last active September 17, 2024 18:14
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/
@tugberkugurlu
tugberkugurlu / gist:2027936
Created March 13, 2012 09:58 — forked from darrelmiller/gist:2026145
ThroughputMessageHandler
public class ThroughputMessageHandler : DelegatingHandler
{
private readonly ILogger _logger;
private Timer _timer;
private int _count;
public ThroughputMessageHandler(ILogger logger)
{
_logger = logger;
_count = 0;
_timer = new Timer(new TimerCallback(timerCallback),null,1000,1000);
@karlseguin
karlseguin / gist:1598236
Created January 12, 2012 02:44
reading length-prefixed streams
class StreamReader
constructor: (@callback) ->
read: (buffer) ->
unless @buffer?
if this.initialize(buffer)
@partial = null
@partialLength = 0
else
return
@davidfowl
davidfowl / Examples
Created May 21, 2011 08:19
Powershell function that recursively walks all project items within a project and lets you execute an action on each one
# Print all project items
Recurse-Project -Action {param($item) "`"$($item.ProjectItem.Name)`" is a $($item.Type)" }
# Function to format all documents based on https://gist.github.com/984353
function Format-Document {
param(
[parameter(ValueFromPipelineByPropertyName = $true)]
[string[]]$ProjectName
)
Process {
@ntotten
ntotten / AccountController.cs
Created March 21, 2011 18:31
ASP.NET MVC 3 Simple Authorization
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Facebook;
using MyFacebookSite3434.Models;
using System.Web.Security;
namespace MyFacebookSite3434.Controllers
@aaronpowell
aaronpowell / NuGet-Updator.ps1
Created March 15, 2011 05:37
Updates all packages across all projects using NuGet
#Created by Steve Godbold
Get-Package -Updates | Update-Package