Skip to content

Instantly share code, notes, and snippets.

View 5argon's full-sized avatar
🏠
Coffee shop programmer 24h

Sirawat Pitaksarit 5argon

🏠
Coffee shop programmer 24h
View GitHub Profile
@5argon
5argon / IntToStringLookup.cs
Last active February 8, 2017 07:23
Make int.ToString() faster to a certain number by changing it to int.ToStringLookup(). Avoiding dynamic memory allocation on the stack but uses more memory on the heap. Use the python program to generate a new lookup array.
public static class IntToStringLookup {
/*
A Python program for you!
import sys
import math
k = 0
@5argon
5argon / srvport.sh
Last active February 20, 2017 02:20
Get an SRV record's port number + target from a URL. (OSX/Linux, or maybe Windows if you have grep) Separated by a whitespace.
URL=$1
nslookup -type=SRV $URL | grep -Eo "service.*" | grep -Eo "[0-9]*[ ][^ ]*$"
@5argon
5argon / GoogleDocsFormatBasic.gs
Created May 22, 2017 11:10
How to format an entire document using RegEx in Google Docs add-on. It will bold my name in string like "5argon : Hello World!"
function formatInkVN() {
var body = DocumentApp.getActiveDocument().getBody();
//all text!
var allText = body.editAsText();
var regexString = "^.*[ ]:[ ]";
var rangeElement = allText.findText(regexString);
while (rangeElement != null) {
var matchedText = rangeElement.getElement().asText();
@5argon
5argon / GoogleDocsBoldAll.gs
Created May 22, 2017 11:12
Google Docs add-ons script to bold everything.
/**
* @OnlyCurrentDoc
*
* The above comment directs Apps Script to limit the scope of file
* access for this add-on. It specifies that this add-on will only
* attempt to read or modify the files in which the add-on is used,
* and not all of the user’s files. The authorization request message
* presented to users will reflect this limited scope.
*/
@5argon
5argon / GoogleDocsHighlighter.gs
Created May 22, 2017 12:08
Highlight a character name (5argon : Hello world!) or any lines that begin with # sign. Each character get different colors via the function at the bottom.
/**
* @OnlyCurrentDoc
*
* The above comment directs Apps Script to limit the scope of file
* access for this add-on. It specifies that this add-on will only
* attempt to read or modify the files in which the add-on is used,
* and not all of the user's files. The authorization request message
* presented to users will reflect this limited scope.
*/
@5argon
5argon / SharpZibLibTest.cs
Last active June 12, 2017 18:04
Compress, decompress example/benchmark test.
using UnityEngine;
using System.Collections;
using System.IO;
using System;
using System.Diagnostics;
using System.Text;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.Cryptography;
using ICSharpCode.SharpZipLib.Core;
@5argon
5argon / FirebaseUnityStudy.cs
Created August 7, 2017 15:01
Study the behavior of Unity Firebase API. Run this one by one so it exits play mode in between tests, clearing everything out as much as possible.
#if UNITY_EDITOR
using System.Collections;
using UnityEngine;
using UnityEngine.TestTools;
using System.Collections.Generic;
using NUnit.Framework;
using Firebase;
@5argon
5argon / OdinBuildSwitcher.cs
Last active May 14, 2018 17:38
A dockable build switcher and defines manager. Edit `Defines` and `AllBuilds` in the code to fit your project.
/// OdinBuildSwitcher
/// 5argon - Exceed7 Experiments
/// http://exceed7.com , 5argon@exceed7.com
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections.Generic;
using System.Linq;
@5argon
5argon / ECSContainerSpeedTest.cs
Created June 9, 2018 09:11
Comparing read-write speed of Unity's ECS native container against regular arrays. Read-write linearly.
using UnityEngine;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Collections;
using Unity.Jobs;
using UnityEngine.Experimental.PlayerLoop;
using System.Collections.Generic;
using System.Diagnostics;
entitiesPerCategory kindsOfCategory categoryToFilter SetFilter ForEachFilter Faster Faster %
10 5 1 38.89 789.89 SetFilter 1931.14%
10 5 1 40.33 953.33 SetFilter 2263.64%
10 5 3 120.78 993.22 SetFilter 722.36%
10 5 5 198.11 1036.56 SetFilter 423.22%
10 10 1 41.11 878.22 SetFilter 2036.22%
10 10 3 125.44 990.22 SetFilter 689.37%
10 10 5 207.89 1227.67 SetFilter 490.54%
10 10 10 415.89 1342.56 SetFilter 222.82%
10 25 1 46.56 936.78 SetFilter 1912.17%