Skip to content

Instantly share code, notes, and snippets.

View kparkov's full-sized avatar

Kristian Videmark Parkov kparkov

View GitHub Profile
@kparkov
kparkov / .wslconfig
Last active October 31, 2022 20:48
WSL2 config allowing a max of 6GB mem usage
# Settings apply across all Linux distros running on WSL 2
[wsl2]
# Limits VM memory to use no more than 6 GB, this can be set as whole numbers using GB or MB
memory=6GB
@kparkov
kparkov / ReplaceMe.vue
Created November 27, 2020 13:02
A base Vue TS component
<template>
<div class="ReplaceMe"></div>
</template>
<style lang="scss" scoped>
.ReplaceMe {
}
</style>
<script lang="ts">
@kparkov
kparkov / Search-And-Explain.ps1
Created November 10, 2020 13:39
Powershell show all properties of the first five results in a list of all markdown files recursively #powershell
dir *.md -Recurse | Select-Object -first 5 | Select-Object -Property *
@kparkov
kparkov / HttpClientExtensions.cs
Last active September 27, 2020 17:03
Http Client unit testing
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace Client.Tests
{
@kparkov
kparkov / ExecuteStringAsCommand.ps1
Last active November 10, 2020 13:39
Execute string as command / script #powershell
$ScriptCommand = [io.path]::Combine($PSScriptRoot, "tasks", "shell", "Subscript.ps1")
& $ScriptCommand
@kparkov
kparkov / run.ps1
Created January 15, 2020 10:23
Run Powershell script during post-build in .NET #powershell #visual-studio #csharp
"C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" -file $(SolutionDir)Powershell\Post-Build.ps1
@kparkov
kparkov / set-screenshot-location.sh
Last active September 27, 2020 16:37
Set location of screenshots in Mac OS
defaults write com.apple.screencapture location ~/Path/To/Folder
@kparkov
kparkov / Example.cs
Created February 27, 2019 23:18
Upload stream
[HttpPost, Route("project/{projectId}/folder/{folderId}/upload")]
public async Task<object> UploadFile(string projectId, string folderId)
{
var request = Request;
// This solution was provided by: http://www.asp.net/web-api/overview/advanced/sending-html-form-data-part-2
// Check if the request contains multipart/form-data.
if (!Request.Content.IsMimeMultipartContent())
{
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
@kparkov
kparkov / TypeSafeEnumAlternative.cs
Last active September 27, 2020 16:38
Type safe Enum alternative
public class Role
{
public static Role Author {get;} = new Role(0, "Author");
public static Role Editor {get;} = new Role(1, "Editor");
public static Role Administrator {get;} = new Role(2, "Administrator");
public static Role SalesRep {get;} = new Role(3, "Sales Representative");
public string Name { get; private set; }
public int Value { get; private set; }