Skip to content

Instantly share code, notes, and snippets.

@techanon
techanon / GetMyComponents.cs
Last active Jan 13, 2021
Type-agnostic transform depth-search algorithm for any component within Udon, just change 'MyComponent' the type you are looking for.
View GetMyComponents.cs
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class GetMyComponents : UdonSharpBehaviour
{
public GameObject[] roots;
[HideInInspector] public MyComponent[] comps;
@techanon
techanon / 1_PickupAsInteract.cs
Last active Oct 27, 2020
Sample concept of using OnPickup inplace of Interact in order to detect the used hand.
View 1_PickupAsInteract.cs
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
[RequireComponent(typeof(VRC_Pickup))]
public class PickupAsInteract : UdonSharpBehaviour
{
[Tooltip("Receives events: OnInteractLeft, OnInteractRight")]
@techanon
techanon / start_avd.bat
Created Mar 31, 2019
Android Emulator boot cmd script
View start_avd.bat
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
SET count=0
FOR /F "tokens=* USEBACKQ" %%F IN (`%ANDROID_HOME%\emulator\emulator.exe -list-avds`) DO (
SET /a count=!count!+1
SET var!count!=%%F
)
for /l %%i in (1,1,%count%) do echo %%i) !var%%i!
@echo digit number of virtual machine to run or 'q' to quit
set /p choice=""
View easy_xpath.js
function getElementsByXpath(path, context) {
if (!context) context = document;
let res = document.evaluate(path, context, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
let tmp, out = [];
while (tmp = res.iterateNext())
out.push(tmp);
return out;
}
@techanon
techanon / quickzip.js
Created May 10, 2018
snippets for quickly zipping either multiple arrays or multiple strings.
View quickzip.js
// Licence: Public domain
function zipArray(...params) {
for (let i in params)
if (!Array.isArray(params[i]))
throw new Error(`All parameters to be zipped MUST be an array. Parameter ${i} is not.`);
let out = [], count = Math.max(...params.map(i=>i.length));
for (let i = 0; i < count; i++) {
for (let param of params) {
if (i < param.length) out.push(param[i]);
@techanon
techanon / temp_proxy_proto_example.js
Created Nov 17, 2017
Proxy protocol on the fly.
View temp_proxy_proto_example.js
class T {
constructor(){
this.value = 'test';
}
test() {
return this.value + '-amend';
}
wrap() {
return proxy(this.test).bind(this);
}
View blurred_background_profile_img_demo.html
<!DOCTYPE html>
<html>
<head>
<style>
/* demo purpose only */
body {display:flex; }
/** CSS **/
.blurbox {
--size: 500px;
@techanon
techanon / emoji.txt
Last active Aug 18, 2020
List of text based emoji cause screw the animated ones.
View emoji.txt
ᕕ( ᐛ )ᕗ
ᕙ( ᐖ )ᕓ
( ͡° ͜ʖ ͡°)
( ‾ʖ̫‾)
¯\_(ツ)_/¯
(ノಠ益ಠ)ノ彡┻━┻
ᕦ(ò_óˇ)ᕤ
ヽ༼ຈل͜ຈ༽ノ
ಠ_ಠ
ಥ‿ಥ
@techanon
techanon / a_filename_parse.regex
Last active Aug 29, 2015
A very long and convoluted regex to dissect a properly named file for music.
View a_filename_parse.regex
(?P<originalartist>.+?) -(?: (?P<albumname>(?:(?! - ).)+) -(?: (?<tracknumber>(?:[0-9][0-9])))?)? (?P<songtitle>(?P<songname>(?:(?! \(ft\.).)+) ?(?:\(ft\. (?P<originalfeaturing>(?:[^)]+?(?:(?=\))|, ))+)\))?(?: \((?:(?P<productionartist>(?:(?!\1 ).+)?) )?(?P<songtype>(?:Remix|VIP|Cover|Version|Instrumental|Parody|Mashup))(?: ft\. (?P<additionalfeaturing>(?:[^)]+?(?:(?=\))|, ))+))?\))?)