Skip to content

Instantly share code, notes, and snippets.

View terence410's full-sized avatar

Terence Tsang terence410

  • Madhead
  • Hong Kong
View GitHub Profile
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"semicolon": [true, "always"],
"no-trailing-whitespace": false,
"arrow-parens": false,
//import {SocketServer} from "./SocketServer";
//const server: SocketServer = new SocketServer();
//server.start();
import Debug from "debug";
import {EventEmitter} from "events";
import * as Http from "http";
import * as SocketIo from "socket.io";
// import {SocketClient} from "./SocketClient";
// const client: SocketClient = new SocketClient("http://127.0.0.1", "userId=1");
import Debug from "debug";
import {EventEmitter} from "events";
import * as SocketIOClient from "socket.io-client";
const debug = Debug("app:SocketClient");
export class SocketClient extends EventEmitter {
using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.TestTools;
namespace Tests
{
@terence410
terence410 / MyMono.cs
Last active January 8, 2021 08:49
Custom Odin Attribute
public class MyMono: MonoBehaviour {
[SelectAsset(SelectFileType.GameObject, "Assets/", "collider", ".wav|.prefab")]
public string MyPrefab;
[SelectAsset(SelectFileType.AudioClip, "Assets/Resources/BGM/", "", ".wav|.mp3")]
public string MyAudioClip;
}
@terence410
terence410 / FpsMono.cs
Last active June 21, 2019 05:56
Unity FPS logging
using UnityEngine;
public class FpsMono : MonoBehaviour
{
private float[] _deltaTimes = new float [600];
private int _deltaTimeIndex = 0;
// Update is called once per frame
void Update()
{
class DecayTween{
constructor({currentValue = 1, targetValue = 1, scaleFactor = 0.2, decayFactor = 0} = {}){
this.currentValue = currentValue;
this.targetValue = targetValue;
this.scaleFactor = scaleFactor;
this.decayFactor = decayFactor;
this.decay = 0;
}
update(){
@terence410
terence410 / dayjs.ts
Last active March 10, 2020 09:41
Day JS
// https://day.js.org/docs/en/display/format
import dayjs, {OpUnitType} from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime";
import utc from "dayjs/plugin/utc";
import weekOfYear from "dayjs/plugin/weekOfYear";
dayjs.extend(utc);
dayjs.extend(weekOfYear);
dayjs.extend(relativeTime);