Skip to content

Instantly share code, notes, and snippets.

View ChaosEngine's full-sized avatar
🚲
HTML5 game designing

Chaos ChaosEngine

🚲
HTML5 game designing
View GitHub Profile
@ChaosEngine
ChaosEngine / WebWorkerify.js
Created November 9, 2020 18:44
WebWorkerify of any JS funcion
Function.prototype.callAsWorker = function (context, args) {
return new Promise((resolve, reject) => {
const code = `
${context ? [...context].reduce((acc, cur) => acc + cur.toString() + '\n') : ''}
self.onmessage = async function (e) {
const result = await ( ${this.toString()}.call(null, e.data) );
self.postMessage( result );
@ChaosEngine
ChaosEngine / netversion.ps1
Created August 4, 2020 07:17
PowerShell script to return versions of .NET Framework on a machine
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse |
Get-ItemProperty -name Version,Release -EA 0 |
Where { $_.PSChildName -match '^(?!S)\p{L}'} |
Select PSChildName, Version, Release
@ChaosEngine
ChaosEngine / repro.sh
Created July 29, 2020 19:59
dotnet docker sdk alpine-3.12 test failing repro
#run latest SDK alpine-3.12 image with dump capabilities
docker run -it --rm --cap-add=SYS_PTRACE mcr.microsoft.com/dotnet/core/sdk:3.1-alpine
#we'll be using git
apk add git
#some trivialities
alias ll='ls -lah --color'
cd /srv/
#clone my repo with tests
@ChaosEngine
ChaosEngine / Samsung_SCX-3400_Series.ppd
Created September 2, 2018 11:13
Samsung SCX-3405W Cups PPD file
*PPD-Adobe: "4.3"
*%%%% PPD file for SCX-3200 with CUPS.
*%%%% Created by the CUPS PPD Compiler CUPS v1.5.0.
*FormatVersion: "4.3"
*FileVersion: "2.0.0"
*LanguageVersion: English
*LanguageEncoding: ISOLatin1
*PCFileName: "scx3200.ppd"
*Product: "(SCX-3200)"
*Manufacturer: "Samsung"
@ChaosEngine
ChaosEngine / ParallelFor.cs
Created July 20, 2018 21:54
Parallel scheme to partition long calculation
async Task<double> ComputeStuffAsync(CancellationToken token)
{
var tsk = Task.Run(() =>
{
var sum = 0.0;
int DOP = 4;
Parallel.For(0, DOP - 1, new ParallelOptions { MaxDegreeOfParallelism = DOP, CancellationToken = token },
// Initialize the local states
() => (double)0.0,
@ChaosEngine
ChaosEngine / Swashbuckle.AspNetCore-issue-600-repro.patch
Created February 22, 2018 21:07
Swashbuckle.AspNetCore/issues/600
diff --git a/test/WebSites/Basic/Basic.csproj b/test/WebSites/Basic/Basic.csproj
index f38e99c..a5c8cf7 100644
--- a/test/WebSites/Basic/Basic.csproj
+++ b/test/WebSites/Basic/Basic.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
- <TargetFramework>netcoreapp2.0</TargetFramework>
+ <TargetFramework>net461</TargetFramework>
@ChaosEngine
ChaosEngine / Ajax-Datatable.cs
Created August 31, 2017 22:51
Cancellationtoken Edge test case
[HttpGet]
public async Task<IActionResult> Load(string sort, string order, string search, int limit, int offset, string extraParam)
{
CancellationToken token = HttpContext.RequestAborted;
try
{
var found = await _repo.SearchAsync(sort, order, search, offset, limit, token);
var result = new
{
@ChaosEngine
ChaosEngine / git-diff.patch
Created July 15, 2017 20:52
https://github.com/aspnet/Caching: dev 2.0.0 patch for building on *nix and Win
diff --git a/samples/MemoryCacheConcurencySample/MemoryCacheConcurencySample.csproj b/samples/MemoryCacheConcurencySample/MemoryCacheConcurencySample.csproj
index b024bae..c758d72 100644
--- a/samples/MemoryCacheConcurencySample/MemoryCacheConcurencySample.csproj
+++ b/samples/MemoryCacheConcurencySample/MemoryCacheConcurencySample.csproj
@@ -3,7 +3,8 @@
<Import Project="..\..\build\dependencies.props" />
<PropertyGroup>
- <TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
+ <TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net461</TargetFrameworks>
@ChaosEngine
ChaosEngine / SessionExtensions.cs
Created May 2, 2017 17:38
SessionExtensions generic type
public static class SessionExtensions
{
public static void Set<T>(this ISession session, string key, T value)
{
session.SetString(key, JsonConvert.SerializeObject(value));
}
public static T Get<T>(this ISession session, string key)
{
var value = session.GetString(key);
@ChaosEngine
ChaosEngine / torvnc
Last active July 21, 2016 21:33
A Dockerfile that builds an image that starts VNC and loads a Tor browser
# DOCKER-VERSION 1.12.0-rc4
# Tor Over VNC
FROM ubuntu:14.04
RUN apt-get update
#RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
# We need sudo because some post install stuff runs with tor
RUN apt-get install -y python-software-properties software-properties-common python3-software-properties sudo wget
RUN add-apt-repository -y ppa:upubuntu-com/tor && apt-get update