Skip to content

Instantly share code, notes, and snippets.

View jonasnordlund's full-sized avatar
🏢
Building our next big thing.

Jonas Nordlund jonasnordlund

🏢
Building our next big thing.
View GitHub Profile
@jonasnordlund
jonasnordlund / ToAscii.ps1
Last active July 22, 2023 13:51
Convert character encoding of files in folder to Windows-1252 / "ANSI"
gci $sourceFolder | % { gc $_.FullName | Set-Content (Join-Path $destFolder $_.Name) -Encoding Windows-1252 }
@jonasnordlund
jonasnordlund / gist:334580f1bfe3feebc4029aa03ee734f7
Created July 2, 2023 22:36
Safely encrypt file with age on Windows Powershell
.\age.exe -o document.pdf.age -r ageXXXXXXX .\document.pdf
.\age.exe -d -i age-identity.txt -o document.pdf .\document.pdf.age
@jonasnordlund
jonasnordlund / WCFSettings.cs
Last active February 23, 2023 11:54
Configuring a WCF service in code
public static class Wcf
{
private static WcfClient _server;
// Set via app.config
public static Uri Address
{
get; set;
}
@jonasnordlund
jonasnordlund / Resolve-SPFRecord.ps1
Created January 17, 2023 10:21
Resolve SPF records of domain name
function Resolve-SPFRecord {
[CmdletBinding()]
param (
# Domain Name
[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
Position = 1)]
[string]$Name,
@jonasnordlund
jonasnordlund / RecentPasswords.ps1
Created July 31, 2022 12:07
Sort BitWarden entries by most recently used
.\bw.exe list items | ConvertFrom-Json | select name, revisiondate | sort revisiondate -desc | more
@jonasnordlund
jonasnordlund / TranscodeToAC3.bat
Created May 14, 2022 13:28
Transcode any audio track to AC3
rem Transcodes any audio track to AC3 while retaining video as-is.
rem Dedicated to the poor bastards with decoders not supporting the
rem ever more popular Dolby Digital Plus codec.
ffmpeg -i "INPUT" -map 0 -c:v copy -c:a ac3 -c:s copy "OUTPUT"
@jonasnordlund
jonasnordlund / Microsoft.PowerShell_profile.ps1
Last active February 13, 2022 13:47
My PowerShell Core profile. Random quote, green/red prompt depending on admin rights, cleaner path for Registry / UNC.
Import-Module Terminal-Icons
function prompt
{
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = [Security.Principal.WindowsPrincipal] $identity
$adminRole = [Security.Principal.WindowsBuiltInRole]::Administrator
$ESC = [char]27
$promptColor = $principal.IsInRole($adminRole) ? "$ESC[91m" : "$ESC[92m"
@jonasnordlund
jonasnordlund / Downlink.ps1
Created December 31, 2019 21:37
Downloads a list of URI's.
@jonasnordlund
jonasnordlund / FormatAspNetDate.js
Created May 3, 2017 07:22
Format ASP .NET web service dates.
/**
* @description Although Microsoft have improved this situation with Web API,
ASP .NET applications still return JSON dates in a proprietary
format similar to "/Date(1320825600000-0800)/". This function
parses these dates into a user locale depending date string.
* @param {string} s The ASP .NET date to parse and format.
* @returns {string} The formatted date.
*/
aspNetDate: function (s) {
var dateParts = s.match(/\/Date\((\d+)[+-](\d+)\)\//);
@jonasnordlund
jonasnordlund / PSTransfer.ps1
Created April 6, 2017 10:52
Transfer files over FTP/HTTP with piping support using Powershell
<#
.SYNOPSIS
Transfers files over HTTP or FTP.
.DESCRIPTION
Downloads or uploads files over HTTP or FTP. Supports user authentication and piped file names.
.PARAMETER UserName
The user account name or an anonymous connection if missing.
.PARAMETER Password
The user account password.
.PARAMETER FileName