Skip to content

Instantly share code, notes, and snippets.

View crpietschmann's full-sized avatar
🌍
We are all human!

Chris Pietschmann crpietschmann

🌍
We are all human!
View GitHub Profile
@crpietschmann
crpietschmann / gist:0fc020010bc6c8df2e015452eb73e2de
Created May 21, 2020 15:20
#MSBuild 2020 Thank You Message Code
/*
This code flashed acros the screen for a momemt in the "Thank You" video Microsoft
published to https://mybuild.microsoft.com/ at the conclusion of the Build 2020 conference.
What does it return?
*/
namespace Snippet
{
public class Program
{
@crpietschmann
crpietschmann / pipeline-variables-pass-variable-between-jobs.yml
Created May 14, 2020 21:47
Azure DevOps Variables - pass variable from on job to another
jobs:
- job: JobOne
pool:
vmImage: 'ubuntu-latest'
steps:
- script: |
NOW=$( date '+%F_%H:%M:%S' )
echo "time value:"
@crpietschmann
crpietschmann / pipeline-pass-variable-between-steps.yml
Last active May 14, 2020 21:42
Azure DevOps Variables - pass variable from on step to another
jobs:
- job: JobOne
pool:
vmImage: 'ubuntu-latest'
steps:
- bash: |
NOW=$( date '+%F_%H:%M:%S' )
echo "##vso[task.setvariable variable=currentTime]$NOW"
displayName: Get Date
@crpietschmann
crpietschmann / KeepAwake.ps1
Last active March 18, 2023 19:29
PowerShell Script to Keep PC Awake
## KeepAwake.ps1
## Use SendKeys to toggle the Scroll Lock key
##
## This will keep the PC awake and prevent
## it from going to sleep.
##
## Author: Chris Pietschmann (https://build5nines.com)
$timerseconds = 60 * 4 ## Every 4 minutes
@crpietschmann
crpietschmann / signCertificateWithRootCACertificate.sh
Created November 8, 2019 20:11
Use OpenSSL to sign an x.509 certificate with another (example Root CA scenario)
# generate custom root CA certificate
openssl req -x509 -newkey rsa:4096 -keyout customRootCA.key -out customRootCA.cer -days 365
# generate leaf certificate
openssl req -x509 -newkey rsa:4096 -keyout leafCert.key -out leafCert.cer -days 365 -subj “/C=/ST=/L=/O=/CN=”
# generate certificate request for the leaf certificate
openssl x509 -x509toreq -days 365 -in leafCert.cer -signkey leafCert.key -out leafCert.req
# sign the leaf certificate request with custom root CA certificate
@crpietschmann
crpietschmann / gencert.sh
Last active February 20, 2024 14:17
OpenSSL Generate 4096-bit Certificate (Public/Private Key Encryption) with SHA256 Fingerprint
# Generate Private Key and Certificate using RSA 256 encryption (4096-bit key)
openssl req -x509 -newkey rsa:4096 -keyout privatekey.pem -out certificate.pem -days 365
# Alternatively, setting the "-newkey" parameter to "rsa:2048" will generate a 2048-bit key.
# Generate PKCS#12 (P12) file for cert; combines both key and certificate together
openssl pkcs12 -export -inkey privatekey.pem -in certificate.pem -out cert.pfx
# Generate SHA256 Fingerprint for Certificate and export to a file
openssl x509 -noout -fingerprint -sha256 -inform pem -in certificate.pem >> fingerprint.txt
@crpietschmann
crpietschmann / Hello-Azure-ARM-Rest-API-ServiceToService.java
Last active August 1, 2018 14:40
Authenticate and Call the Azure Resource Manager (ARM) REST API from Java - Service to Service Authentication
package javaapplication1;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
// https://hc.apache.org/
import org.apache.http.HttpEntity;
@crpietschmann
crpietschmann / Hello-Azure-AD-REST-API-Service-To-Service.java
Last active November 11, 2021 20:39
Authenticate and Call the Azure AD Graph REST API from Java - Service to Service Authentication
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
// https://hc.apache.org/
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
@crpietschmann
crpietschmann / PiIoTPoliceMainpage.xaml.cs
Last active August 1, 2018 00:05
Sample code for the simple #IoT Police lights demo using Windows 10 IoT Core and a Raspberry Pi 3 with a couple LEDs https://twitter.com/BuildIoTCore/status/756542703786229764
/// License: Public Domain
/// Written by: Chris Pietschmann
/// http://pietschsoft.com
/// http://BuildAzure.com
/// http://BuildIoTCore.com
///
/// This is the code behind the simple "#IoT police lights" shown
/// in the video at the following URL:
/// https://twitter.com/BuildIoTCore/status/756542703786229764
///