Skip to content

Instantly share code, notes, and snippets.

View i-e-b's full-sized avatar
🤔
Thinking

Iain Ballard i-e-b

🤔
Thinking
View GitHub Profile
@i-e-b
i-e-b / EC2 dotnet core setup.md
Created March 11, 2020 11:39
Setup dotnet core 3.1 website on AWS EC2 instance, using S3 bucket for storage

Put your software in an S3 bucket

Publish your web app, check it works locally. Zip the files into a single archive.

Go to AWS console, and S3 buckets. Create a bucket for your compiled app artefacts.

Upload your zip file.

@i-e-b
i-e-b / xoshiro256mul.cs
Created January 14, 2020 12:27
xoshiro256** implementation in C#, based on the Wikipedia code at https://en.wikipedia.org/wiki/Xorshift#xoshiro256**
static void Main(string[] args)
{
var seed = 123456UL;
var state = xorshift256_init(seed);
for (var i = 0; i < 20; i++) {
Console.WriteLine(xoshiro256p(state).ToString("x"));
}
Console.ReadLine();
@i-e-b
i-e-b / NoTable_CRC32.cs
Created September 27, 2019 13:11
CRC32 with no lookup table
private static uint NoTableCrc(uint prevCrc, [NotNull]byte[] buffer)
{
// this uses no table, but more operations.
// it's *much* slower than the table approach, but can be used in very constrained environments.
var len = buffer.Length;
var i = 0;
var crc = ~prevCrc;
while (len-->0) {
crc ^= buffer[i++];
@i-e-b
i-e-b / hqx.cpp
Created July 26, 2019 14:47
Table lookup version of HQX2
#include <nall/platform.hpp>
#include <nall/stdint.hpp>
using namespace nall;
extern "C" {
void filter_size(unsigned&, unsigned&);
void filter_render(uint32_t*, uint32_t*, unsigned, const uint16_t*, unsigned, unsigned, unsigned);
};
enum {
@i-e-b
i-e-b / triggerBuild.ps1
Created June 5, 2019 10:31
How to trigger a TFS build from Powershell
$b= '{"buildNumber":534,"definition":{"id":534}}'
$user="GOCOMPARE\IainBallard"
$token="fqul...<make a PAT token>...qq"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("${user}:${token}"))
$Uri = "https://tfs.gocompare.local/Gocompare/GoCompare.Contracts/_apis/build/builds?api-version=4.1"
$buildresponse = Invoke-RestMethod -Method Post -UseDefaultCredentials -ContentType application/json -Uri $Uri -Body $b -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
write-host $buildresponse
@i-e-b
i-e-b / stx2.c
Last active January 6, 2020 14:53
An interesting (incomplete) algorithm for the ST2 transform: Schindler-Transform
// A sort based transform, like BWT
// From
// https://encode.ru/threads/1317-Schindler-Transform-(STX)
// See also:
// http://www.compressconsult.com/st/
// https://ieeexplore.ieee.org/document/1607307
uint Forward_ST2( byte* inpbuf, byte* outbuf, uint inplen ) {
uint i,c,p,q;
@i-e-b
i-e-b / Raw SOAP samples.md
Created May 1, 2019 10:50
Raw SOAP samples

SOAP 1.1 looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> 
    <env:Header>
    </env:Header>
    <env:Body>
        <p:MyStuff xmlns:p="http://mynamespace.example.com">
            ...
 
@i-e-b
i-e-b / dwt97.c
Created March 5, 2019 09:57
Fast discrete biorthogonal CDF 9/7 wavelet forward and inverse transform (lifting implementation)
/**
* dwt97.c - Fast discrete biorthogonal CDF 9/7 wavelet forward and inverse transform (lifting implementation)
*
* This code is provided "as is" and is given for educational purposes.
* 2006 - Gregoire Pau - gregoire.pau@ebi.ac.uk
*/
#include <stdio.h>
#include <stdlib.h>
@i-e-b
i-e-b / ResharperAnnotations.cs
Created February 4, 2019 09:29
Minimal annotations for JetBrains' Resharper
using System;
#pragma warning disable 1591
// ReSharper disable once CheckNamespace
namespace JetBrains.Annotations {
/// <summary>Marked element could be <c>null</c></summary>
[AttributeUsage(AttributeTargets.All)] internal sealed class CanBeNullAttribute : Attribute { }
/// <summary>Marked element could never be <c>null</c></summary>
[AttributeUsage(AttributeTargets.All)] internal sealed class NotNullAttribute : Attribute { }
/// <summary>IEnumerable, Task.Result, or Lazy.Value property can never be null.</summary>
[AttributeUsage(AttributeTargets.All)] internal sealed class ItemNotNullAttribute : Attribute { }
@i-e-b
i-e-b / SaneTypeName.cs
Created December 5, 2018 08:26
Output a stringified type name for display or key purposes. Much more concise and readable than `Type.FullName` in the case of generics.
public static string NameForType(Type type)
{
if (!type.IsConstructedGenericType) return (type.FullName ?? "<null>");
var container = type.Name;
var contents = type.GenericTypeArguments?.Select(SessionKeyNameForType) ?? new[] { "empty!" };
return container.Substring(0, container.Length - 2) + "<" + string.Join(",", contents) + ">"; // assumes < 10 generic type params
}