Skip to content

Instantly share code, notes, and snippets.

@amake
amake / innosetup-linux-macos.org
Last active May 22, 2024 06:31
Inno Setup on Linux and macOS

Inno Setup on Linux and macOS

Inno Setup is a popular installer builder for Windows. Of course it is made to run on Windows only, by default. But what if you want to build Windows installers off Windows, i.e. on Linux or macOS?

You’re in luck: It’s possible to run Inno Setup anywhere that Docker runs (including Linux and macOS), and even have a passable experience writing your setup script.

@ghostbust555
ghostbust555 / Install-Python-Environment.ps1
Last active March 28, 2018 19:38
Pull down and create python environment
$outputDir = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$PSScriptRoot/../python")
$zipOutput = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$PSScriptRoot/../Framework/Neural.DocumentRecognition/pythonEnvironment.zip")
if(-not (test-path $outputDir) -or -not (test-path $zipOutput)){
if(-not (test-path "$PSScriptRoot/minicondaInstaller.exe")){
Invoke-WebRequest -Uri "https://repo.continuum.io/miniconda/Miniconda3-4.4.10-Windows-x86_64.exe" -OutFile "$PSScriptRoot/minicondaInstaller.exe"
}
& "$PSScriptRoot/minicondaInstaller.exe" /InstallationType=JustMe /RegisterPython=0 /NoRegistry=1 /S /D="$outputDir" | Out-Null
@Sh1n0g1
Sh1n0g1 / Helloworld_C_Sharp.ps1
Created August 26, 2017 01:33
Run C# code in PowerShell
$assemblies=(
"System"
)
$source=@"
using System;
namespace Helloworld
{
public static class Hello{
public static void Main(){
@JamesRandall
JamesRandall / RedirectNewtonsoftJson.ps1
Last active May 2, 2023 13:39
Powershell binding redirection
# Load your target version of the assembly
$newtonsoft = [System.Reflection.Assembly]::LoadFrom("$PSScriptRoot\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll")
$onAssemblyResolveEventHandler = [System.ResolveEventHandler] {
param($sender, $e)
# You can make this condition more or less version specific as suits your requirements
if ($e.Name.StartsWith("Newtonsoft.Json")) {
return $newtonsoft
}
foreach($assembly in [System.AppDomain]::CurrentDomain.GetAssemblies()) {
if ($assembly.FullName -eq $e.Name) {
/// <summary>
/// Executes the given async delegates in parallel,
/// up to the given maximum degree of parallelism.
/// </summary>
public static async Task InvokeAsync(IEnumerable<Func<Task>> taskFactories, int maxDegreeOfParallelism)
{
if (taskFactories == null) throw new ArgumentNullException(nameof(taskFactories));
if (maxDegreeOfParallelism <= 0) throw new ArgumentException(nameof(maxDegreeOfParallelism));
// Defensive copy. Similar to what Task.WhenAll/WhenAny does.
@vendettamit
vendettamit / InMemoryNunitTestRunner
Created July 25, 2014 09:51
InMemory NunitTestRunner
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
@TemporaryJam
TemporaryJam / Howto convert a PFX to a seperate .key & .crt file
Last active April 4, 2024 10:52
How to convert a .pfx SSL certificate to .crt/key (pem) formats. Useful for NGINX
source: http://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/
`openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]`
What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.
Now let’s extract the certificate:
`openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]`
@jbtule
jbtule / AESGCM.cs
Last active October 30, 2023 21:14
I have two code examples that I wrote for best practices encrypting a string in c#. They are both using authenticated encryption. http://stackoverflow.com/a/10366194/637783
/*
* This work (Modern Encryption of a String C#, by James Tuley),
* identified by James Tuley, is free of known copyright restrictions.
* https://gist.github.com/4336842
* http://creativecommons.org/publicdomain/mark/1.0/
*/
using System;
using System.IO;
using System.Text;