Skip to content

Instantly share code, notes, and snippets.

var readDirectory = async () => {
const opts = { type: 'open-directory' };
const handle = await window.chooseFileSystemEntries(opts);
const entries = await handle.getEntries();
window.entries = entries;
for await (const entry of entries) {
const kind = entry.isFile ? 'File' : 'Directory';
console.log(kind, entry.name);
}
{
"files.exclude": {
"**/*.js": true,
"**/*.js.map": true,
"**/*.njsproj": true,
"**/*.njsproj.user": true,
"bin/": true,
"node_modules/": true,
"obj/": true,
"package-lock.json": true
@xsolon
xsolon / test.js
Last active August 3, 2018 01:50
BlogGist
function test(){
alert('hi');
}
@xsolon
xsolon / pfx_acl.ps1
Created November 4, 2017 14:34
Pfx access for application pool
$friendlyName = 'cert friendly name'
$location = 'Cert:\LocalMachine\my';
#get cert by friendly name
$cert = Get-ChildItem -Path $location | Where { $_.FriendlyName -eq $friendlyName};
#location of pfx on file system
$keyName = $cert.PrivateKey.CspKeyContainerInfo.UniqueKeyContainerName
$keyPath = [System.IO.Path]::Combine("$env:ProgramData\Microsoft\Crypto\RSA\MachineKeys\",$keyName)
@xsolon
xsolon / SimpleSelfSignedCert.ps1
Created October 23, 2017 10:16
Self Signed Certificate with PowerShell
# Create certificate -------------------------------------------------------------
$encrptCertFriendlyName = 'myCert'
$pfxPassWord = 'passwordCert'
$location = 'Cert:\LocalMachine\my';
# This command needs to run on a modern powershell (win 10/server 2016, PSVersion >= 5.1)
$cert = New-SelfSignedCertificate -CertStoreLocation $location -Subject $encrptCertFriendlyName -KeySpec KeyExchange -NotAfter (Get-Date).AddYears(20) -FriendlyName $encrptCertFriendlyName -Type Custom
$mypwd = ConvertTo-SecureString -String $pfxPassWord -Force -AsPlainText
Export-pfxCertificate -FilePath 'c:\myCert.pfx' -Cert $cert -Password $mypwd
@xsolon
xsolon / CaCerts.ps1
Last active October 23, 2017 10:15
Create CA cert and certificates using PowerShell
# based on https://technet.microsoft.com/en-us/library/dn949332.aspx
# This command needs to run on a modern powershell (win 10/server 2016, PSVersion >= 5.1)
#local certificate authority
$caFriendlyName = "myCA";
$caSubjectName = "myCA";
#server to server cert
$encrptCertFriendlyName = "EncryptCert";
@xsolon
xsolon / dsc_sql_firewall_instance.ps1
Created October 21, 2017 16:49
DSC Firewall rules for sql instance using dynamic ports
Configuration SqlFirewallApp2
{
#Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DSCResource -ModuleName xNetworking
node $env:ComputerName
{
# instance rule
xFireWall SQLFirewallRule
@xsolon
xsolon / dsc_sqlAlias_simple.ps1
Last active October 21, 2017 16:48
Dsc - Sql Alias
#Install-PackageProvider -Name Nuget -MinimumVersion 2.8.5.201
Configuration sqlAlias
{
Import-Module PSDesiredStateConfiguration -ErrorAction SilentlyContinue
Import-Module xSQLServer -ErrorAction SilentlyContinue
if ((get-module -Name PSDesiredStateConfiguration) -eq $null){
Install-Module PSDesiredStateConfiguration -Force
Import-Module PSDesiredStateConfiguration
}
@xsolon
xsolon / _spPageContextInfo.sample.json
Last active November 24, 2015 08:01
SharePoint JSOM: Check permissions of current page
_spPageContextInfo
{
webServerRelativeUrl : "/ProjectWeb",
webLanguage : 1033,
currentLanguage : 1033,
webUIVersion : 4,
pageListId : "{c1d7b89f-f07b-4e2e-b89c-76c315831d59}",
pageItemId : 5,
userId : 68,
alertsEnabled : true,