Skip to content

Instantly share code, notes, and snippets.

View johnkors's full-sized avatar

John Korsnes johnkors

View GitHub Profile
@johnkors
johnkors / shellcmds.md
Last active August 8, 2017 07:57
Useful shell cmds

Split a file

Ex. split log file into 50MB chunks, use digits as postfix, use file-ending .log on created files

λ split MyHugeFileOfManyGBs.log -C 50m -d --additional-suffix .log

List contents of files

  • cat
  • type
@johnkors
johnkors / Shell log.md
Last active August 4, 2017 12:30
Experiences using azure container instances

A small journey into azure container instances

λ az account list-locations | grep europe
    "id": "/subscriptions/be95d17f-ed23-4a74-b61f-56d51845f744/locations/northeurope",
    "name": "northeurope",
    "id": "/subscriptions/be95d17f-ed23-4a74-b61f-56d51845f744/locations/westeurope",
    "name": "westeurope",
@johnkors
johnkors / vscode.bat
Created July 24, 2017 11:46
bat file to fix setting up cmder correctly inside vscode as the integrated terminal
@echo off
SET CMDER_ROOT=C:\tools\cmder
"%CMDER_ROOT%\vendor\init.bat"
@johnkors
johnkors / settings.json
Created July 24, 2017 11:45
VS Code user settings
// Place your settings in this file to overwrite the default settings
{
"editor.renderWhitespace": "all",
"window.zoomLevel": 0,
"workbench.iconTheme": "vscode-icons",
"vsicons.projectDetection.autoReload": true,
"workbench.activityBar.visible": false,
"workbench.statusBar.visible": false,
"editor.minimap.enabled": false,
"terminal.integrated.shell.windows": "C:\\WINDOWS\\Sysnative\\cmd.exe",
@johnkors
johnkors / .gitconfig
Last active August 6, 2017 08:24
git diff using word highlighting
[user]
name = mynanme
email = [email protected]
[credential]
helper = wincred
[push]
default = simple
[diff]
tool = bc3
[difftool]
@johnkors
johnkors / git-prune-merged.ps1
Last active March 22, 2023 22:23
PowerShell script to delete branches merged to master
# update local list of pruned branches on the remote to local:
git fetch --prune
# delete branches on remote origin that have been merge to master
git branch --merged remotes/origin/master -r | %{$_.trim().replace('origin/', '')} | ?{$_ -notmatch 'master'} | %{git push --delete origin $_}
# delete local branches that have been merged to master
git branch --merged remotes/origin/master | %{$_.trim()} | ?{$_ -notmatch 'master'} | %{git branch -d $_}
# remove stale refs (local refs to branches that are gone on the remote)
@johnkors
johnkors / DiscourseController.cs
Last active February 7, 2017 13:23
Create discourse URL response
private static string CreateDiscourseRedirectUrl(InMemoryUser user, string originalEncodedsso)
{
var urlParameters = Parsesso(originalEncodedsso);
var nonce = urlParameters.Get("nonce");
var returnUrl = urlParameters.Get("return_sso_url");
ValidateKnownurl(returnUrl);
var ssoDictionary = new Dictionary<string, string>
{
{"nonce", nonce},
@johnkors
johnkors / DiscourseController.cs
Last active February 3, 2017 16:31
POST /core/discourse/login
[Route("core/discourse/login")]
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Login(string username, string password)
{
if (Users.PasswordMatch(username, password))
{
var user = Users.GetUser(username);
var authLogin = new AuthenticatedLogin
@johnkors
johnkors / DiscourseController.cs
Created February 3, 2017 16:22
/core/discourse
// Redirected from Discourse
[Route("core/discourse")]
[HttpGet]
public async Task<ActionResult> Index(string sso, string sig)
{
if (!IsValid(sso, sig))
{
throw new SecurityException("sso sig not valid");
}
@johnkors
johnkors / DiscourseController.cs
Last active February 3, 2017 15:09
/core/discourse
[Route("core/discourse")]
[HttpGet]
public async Task<ActionResult> Index(string sso, string sig)
{
if (string.IsNullOrEmpty(sso) || string.IsNullOrEmpty(sig))
{
throw new ArgumentException("Missing input parameters");
}
if (!IsValid(sso, sig))