Skip to content

Instantly share code, notes, and snippets.

Avatar

A. Matías Quezada amatiasq

View GitHub Profile
View html5-dnd.html
<!DOCTYPE html>
<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
</head>
<body>
<div id="app">
<div class="left">Left</div>
@amatiasq
amatiasq / 1-ExposedReferencesTable.cs
Last active February 3, 2023 13:14
Using ExposedReferences in Unity
View 1-ExposedReferencesTable.cs
using System.Collections.Generic;
using UnityEngine;
public class ExposedReferencesTable : MonoBehaviour, IExposedPropertyTable
{
public List<PropertyName> properties = new();
public List<Object> references = new();
public T Get<T>(ExposedReference<T> reference) where T : Object
{
@amatiasq
amatiasq / odin.cs
Last active January 12, 2023 15:11
View odin.cs
class Example : MonoBehaviour {
// Assets only
[AssetsOnly]
public GameObject SomePrefab;
[AssetsOnly]
public List<GameObject> OnlyPrefabs;
// SceneObjectsOnly
[SceneObjectsOnly]
public GameObject SomeSceneObject;
View fake-click.js
button.click(); // nothing
event = document.createEvent ('MouseEvents');
event.initEvent('click', true, true);
button.dispatchEvent(click) // nothing
// here I discover `event.isTrusted`
event = document.createEvent ('MouseEvents');
event.initEvent('click', true, true);
View interface-segregation.cs
using System;
// Interface segregation
interface ISimulationReporter<TResult>
{
event Action<TResult> OnComplete;
}
interface ISimulationRunner<TInput>
View netcode.test.ts
import { equal } from 'assert';
import { FIRST_FRAME } from './Netcode';
import { NetcodeClient } from './NetcodeClient';
import { NetcodeServer } from './NetcodeServer';
type UserId = 'a' | 'b';
type Input = 'RUN' | null;
interface Entity {
x: number;
@amatiasq
amatiasq / new.js
Created December 10, 2013 15:45
A simple .new() method to create instances without constructors. This allow us to rewrite the "new" in order to do other things but create objects.
View new.js
function $new() {
var obj = Object.create(this);
obj.init.apply(obj, arguments);
return obj;
}
@amatiasq
amatiasq / .jshintrc
Created September 3, 2014 08:28
JSHint config
View .jshintrc
{
// JSHint Default Configuration File (as on JSHint website)
// See http://jshint.com/docs/ for more details
"maxerr" : 50, // {int} Maximum error before stopping
// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : true, // true: Identifiers must be in camelCase
"curly" : false, // true: Require {} for every new block or scope
View ts-mockito.ts
import { mock, instance, when, verify, anything } from 'ts-mockito';
const mockedFoo: Foo = mock(Foo);
// stub method before execution
when(mockedFoo.getBar(3)).thenReturn('three');
// Getting instance from mock
const foo: Foo = instance(mockedFoo);
@amatiasq
amatiasq / esm.ts
Last active September 23, 2021 11:57
View esm.ts
const extensions = {
js: 'application/javascript',
ts: 'application/typescript',
jsx: 'text/jsx',
tsx: 'text/tsx',
} as const;
type Extensions = typeof extensions;
type ValidExtension = keyof Extensions;
type ValidMediaType = Extensions[ValidExtension];