Skip to content

Instantly share code, notes, and snippets.

Avatar
🚲
HTML5 game designing

Chaos ChaosEngine

🚲
HTML5 game designing
View GitHub Profile
@ChaosEngine
ChaosEngine / WebWorkerify.js
Created Nov 9, 2020
WebWorkerify of any JS funcion
View WebWorkerify.js
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 Aug 4, 2020
PowerShell script to return versions of .NET Framework on a machine
View netversion.ps1
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 Jul 29, 2020
dotnet docker sdk alpine-3.12 test failing repro
View repro.sh
#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 Sep 2, 2018
Samsung SCX-3405W Cups PPD file
View Samsung_SCX-3400_Series.ppd
*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 Jul 20, 2018
Parallel scheme to partition long calculation
View ParallelFor.cs
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,
View Swashbuckle.AspNetCore-issue-600-repro.patch
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 Aug 31, 2017
Cancellationtoken Edge test case
View Ajax-Datatable.cs
[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 Jul 15, 2017
https://github.com/aspnet/Caching: dev 2.0.0 patch for building on *nix and Win
View git-diff.patch
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
SessionExtensions generic type
View SessionExtensions.cs
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 Jul 21, 2016
A Dockerfile that builds an image that starts VNC and loads a Tor browser
View torvnc
# 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