Skip to content

Instantly share code, notes, and snippets.

View dg1an3's full-sized avatar
🧩
putting together the pieces

Derek dg1an3

🧩
putting together the pieces
View GitHub Profile
@dg1an3
dg1an3 / Get-AppConfig.ps1
Created August 18, 2022 22:05
App config powershell helpers
param([String]$key)
Get-ChildItem .\*.config -Recurse |
Where-Object { ([xml](Get-Content $_)).SelectSingleNode("//add[@key='$key']") } |
ForEach-Object {
$xml = [xml](Get-Content $_)
$xml.SelectSingleNode("//add[@key='$key']").Value
}
@dg1an3
dg1an3 / ImagingLab.ps1
Created February 11, 2022 22:15
Imaging Lab DSC nodes
<#
Powershell DSC resources for setting up an imaging network, based on the PSAutoLab PowerShelllab network
#>
Configuration ImagingLab
{
Import-DscResource -ModuleName PSDesiredStateConfiguration -ModuleVersion 1.1
Import-DscResource -ModuleName ComputerManagementDSC -ModuleVersion 8.5.0
Import-DscResource -ModuleName NetworkingDSC -ModuleVersion 8.2.0
Import-DscResource -ModuleName xNetworking
Import-DscResource -ModuleName DSCR_FileContent -ModuleVersion 2.4.2
@dg1an3
dg1an3 / mock_session_dates.py
Created January 13, 2021 15:29
python code to create a random series of session dates
def date_from_workday(workday_num):
return datetime.strptime(f"2021-W{workday_num//5+1}-{workday_num%5+1}", '%Y-W%W-%w')
def generate_session_dates(session_count=15, start_workday=None):
session_dates = []
session_workday = start_workday if start_workday else randint(0,200)
for n in range(session_count):
session_dates.append(date_from_workday(session_workday))
session_workday += 1 if randint(0,5) else 2
return session_dates
@dg1an3
dg1an3 / repo_status.ps1
Created November 11, 2019 23:42
get the status of all git repos from a common parent directory
gci . |?{$_.PSIsContainer}|?{Test-Path $_\.git}|foreach {pushd $_; git status; popd}
Get-WmiObject -Class Win32_Product | ?{$_.Name -like "Python 3.*" | Format-Table
Get-WmiObject -Class Win32_Product | ?{$_.Name -like "Python 3.*" | foreach {$_.Uninstall()}
@dg1an3
dg1an3 / ballot.sol
Created October 25, 2019 14:56
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.12+commit.7709ece9.js&optimize=false&gist=
pragma solidity ^0.5.12;
contract PhotoContestContract {
bytes32 _name;
address _owner;
bytes32[] _ipfsPhotoHashes;
address payable[] _submissionAddresses;
constructor(bytes32 name) public {
_owner = msg.sender;
_name = name;
@dg1an3
dg1an3 / ballot.sol
Created October 24, 2019 21:41
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.17+commit.bdeb9e52.js&optimize=false&gist=
pragma solidity ^0.4.17;
contract Contract {
string ipfsHash;
function setHash(string x) public {
ipfsHash = x;
}
function getHash() public view returns (string x) {
return ipfsHash;
}
}
@dg1an3
dg1an3 / CreateTypeForSvcInterface.cs
Last active April 8, 2019 20:52
generate a dynamic empty wcf interface, given a name and namespace
string source = string.Format(@"
using System.ServiceModel;
namespace CreateTypeForSvcNamespace
{{
[ServiceContract(Namespace=""{0}"",Name=""{1}"")]
public interface {1} {{ }}
}}", ns, name);
var asmName = Path.GetRandomFileName();
var compilation = CSharpCompilation.Create(asmName,
@dg1an3
dg1an3 / findinterfaces.bat
Created February 23, 2019 20:57
find public interfaces
findstr /S/R "public.interface" *.cs
@dg1an3
dg1an3 / allgit.bat
Created February 23, 2019 20:54
findstr for git repo urls
findstr /S "version" config