Skip to content

Instantly share code, notes, and snippets.

View dfbaskin's full-sized avatar

Dave F. Baskin dfbaskin

View GitHub Profile
@dfbaskin
dfbaskin / VisualStudioCommandLine.ps1
Last active January 4, 2024 15:28
Set up Visual Studio command line shell in PowerShell (v7+)
param (
[string] $name = 'Visual Studio Enterprise 2022'
)
$VSInstance = Get-CimInstance MSFT_VSInstance -Namespace root/cimv2/vs |
Where-Object { $_.ElementName -eq $name }
if (-not $VSInstance) {
throw "Could not find Visual Studio installation details."
}
@dfbaskin
dfbaskin / useOverrides.spec.tsx
Created September 14, 2021 20:11
useOverrides hook to replace component hooks, elements, whatever for testing and Storybook.
import { render } from '@testing-library/react';
import { screen } from '@testing-library/dom';
import { useOverrides } from '../useOverrides';
import '@testing-library/jest-dom';
function useFakeTranslation(textId: string) {
return `${textId.toUpperCase()}-XLATED`;
}
function TestIcon() {
@dfbaskin
dfbaskin / generate-dev-certs.ps1
Last active August 26, 2021 13:51
Using .NET Core Development Certificates with Node
$certsPath = Join-Path $PSScriptRoot "certs"
if(!(Test-Path $certsPath)) {
New-Item -Path $PSScriptRoot -Name "certs" -ItemType "directory" | Out-Null
}
Push-Location $certsPath
$gitPath = $env:Path.Split(';') |
Where-Object { Test-Path $_ } |
@dfbaskin
dfbaskin / MyProfileName.ps1
Created August 16, 2021 14:48
Run multiple Teams Desktop applications in Windows
$profileName = [io.path]::GetFileNameWithoutExtension($PSCommandPath)
Write-Output "Launching $profileName Teams Profile ..."
$userProfile = $env:USERPROFILE
$appDataPath = $env:LOCALAPPDATA
$customProfile = "$appDataPath\Microsoft\Teams\CustomProfiles\$profileName"
$downloadPath = Join-Path $customProfile "Downloads"
if (!(Test-Path -PathType Container $downloadPath)) {
New-Item $downloadPath -ItemType Directory |
@dfbaskin
dfbaskin / run-projects.ps1
Created August 31, 2020 11:49
Use Powershell Core and Microsoft Terminal to open node and dotnet application side-by-side.
param (
$shellName = 'pwsh'
)
$commands = @(
[PSCustomObject]@{
Path = 'my-node-project'
Command = 'npm.cmd start'
Window = 'new-tab'
}
(function() {
var img = document.querySelector("img[src='https://www.wintellect.com/wp-content/uploads/2017/09/clip_image002_thumb.jpg']");
var imgRect = img.getBoundingClientRect();
var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
var cw = function(w) { return imgRect.width * (w/100); }
var ch = function(h) { return imgRect.height * (h/100); }
var cnv = document.createElement("canvas");
cnv.style.position = "absolute";
cnv.style.top = imgRect.top + scrollTop + "px";
import {ActionsObservable as Observable} from 'redux-observable'
import {VirtualTimeScheduler} from 'rxjs/scheduler/VirtualTimeScheduler';
import 'rxjs/add/observable/empty';
import 'rxjs/add/observable/interval';
import 'rxjs/add/operator/delay';
import 'rxjs/add/operator/concat';
import 'rxjs/add/operator/reduce';
import 'rxjs/add/operator/takeUntil';
$routeProvider.when('/detail/:id', {
templateUrl: '/Home/Detail',
controller: 'detailCtrl',
});
<div class="container">
 
    <form name="personForm" class="ng-cloak">
        <fieldset>
       
            <legend>Person Details</legend>
             
            <div class="row-fluid">
         
                <div class="control-group">
angular
.module('myApp.ctrl.detail', [])
.controller('detailCtrl', ['$scope', '$http', '$routeParams', '$location', function ($scope, $http, $routeParams, $location) {
$scope.person = {
title: '',
firstName: '',
middleName: '',
lastName: '',
suffix: ''