Skip to content

Instantly share code, notes, and snippets.

@NickStrupat
NickStrupat / maps-grouping.ts
Last active April 12, 2019 18:04
Grouping using maps example (now with es5)
class Person {
name!: string;
age!: number;
sex!: string;
public toString = () : string => JSON.stringify(this);
}
const people: Person[] = [
{ age: 25, sex: 'f', name: 'Sue' },
{ age: 30, sex: 'f', name: 'Angela' },
@NickStrupat
NickStrupat / save_excel_to_json.vb
Created March 26, 2019 19:33
UTF-8 and double quote escaping. It saves the file beside the active workbook file but with the .json file extension. It's fast. It can be easily formatted in VS Code (Shift + Alt + F). To use it, hit Alt + F11 to get to the VBA code editor, open the code for your active worksheet, then paste it into the code window. Hit F5 to run.
Public Sub tojson()
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
jsonFilename = fso.GetBaseName(ActiveWorkbook.Name) & ".json"
fullFilePath = Application.ActiveWorkbook.Path & "\" & jsonFilename
Dim fileStream As Object
Set fileStream = CreateObject("ADODB.Stream")
fileStream.Type = 2 'Specify stream type - we want To save text/string data.
fileStream.Charset = "utf-8" 'Specify charset For the source text data.
#pragma once
#include <cstdint>
#include <new>
#include <limits>
#include <intrin.h>
namespace cova::mem
using System;
using System.Collections.Generic;
class ArrayEqualityComparer<TElement> : IEqualityComparer<TElement[]>
{
public static readonly ArrayEqualityComparer<TElement> Default =
new ArrayEqualityComparer<TElement>(EqualityComparer<TElement>.Default);
private readonly IEqualityComparer<TElement> elementEqualityComparer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
namespace NickStrupat
{
public static class ModuleBuilderExtensions
{
powershell -Command "Invoke-WebRequest https://repo.anaconda.com/archive/Anaconda3-5.3.0-Windows-x86_64.exe"
start /wait "" Anaconda3-5.3.0-Windows-x86_64.exe /InstallationType=JustMe /RegisterPython=0 /S /D=%UserProfile%\Anaconda3
cmd "/K" %UserProfile%\Anaconda3\Scripts\activate.bat %UserProfile%\Anaconda3
conda update -y conda
conda update -y anaconda
conda update -y python
conda update -y --all
conda create --name tf-gpu
@NickStrupat
NickStrupat / SplitIntoAll.cs
Last active October 2, 2018 18:09
Split sentence into all possible combinations of sub-sentences
using System;
using System.Collections.Generic;
using System.Linq;
namespace WhaHappen
{
public static class StringExtensions
{
public static IEnumerable<String> SplitIntoAll(this String s, Char delimiter = ' ')
{
$isDesktop = $PSEdition -eq "Desktop"
$isCore = $PSEdition -eq "Core"
if ($isDesktop -or ($isCore -and $IsWindows)) {
Write-Output Windows
}
elseif ($isCore -and $IsLinux) {
Write-Output Linux
}
elseif ($isCore -and $IsMacOS) {
Write-Output macOS
@NickStrupat
NickStrupat / docker-run.ps1
Created July 5, 2018 06:05
Pass domain and user names into docker container
docker run -it -e DOCKER_HOST_USER_DOMAIN_NAME=$([System.Environment]::UserDomainName) -e DOCKER_HOST_USER_NAME=$([System.Environment]::UserName) mcr.microsoft.com/powershell
Enum OSType {
Windows
Linux
}
function Ensure-Docker-Container-Engine-Mode([OSType] $osType) {
[OSType] $currentOSType = docker info --format "{{.OSType}}"
Write-Output "Current engine: $($currentOSType)"
Write-Output "Requested engine: $($osType)"
if ($currentOSType -eq $osType) {