Skip to content

Instantly share code, notes, and snippets.

@marcusx2
marcusx2 / gist:9b927a46a397f6e181bd2eb3ab0718d8
Last active March 17, 2021 15:30
cloud function block create
//only allow to sign up if the user exists on firestore.
const functions = require('firebase-functions');
const admin = require("firebase-admin");
admin.initializeApp();
exports.blockSignup = functions.auth.user().onCreate(user => {
return new Promise((resolve, reject) => {
admin.firestore().collection('users').doc(user.email).get().then(doc => {
if (doc.exists) {
@marcusx2
marcusx2 / firebase read only by email
Last active November 7, 2020 22:45
firebase rule to allow only read corresponding document by registered user
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userEmail} {
allow read: if request.auth.token.email.lower() == userEmail.lower();
}
}
}
@marcusx2
marcusx2 / UnityGAWebGL
Created September 8, 2020 20:01
Google Analytics WebGL
//GoogleAnalytics.jslib
mergeInto(LibraryManager.library, {
sendGoogleAnalyticsEvent: function(hspt) {
gtag('event', 'Click', {
'event_category' : 'Hotspot',
'event_label' : Pointer_stringify(hspt)
});
}
});
@marcusx2
marcusx2 / netlify.toml
Last active October 10, 2021 22:18
custom headers for brotli compression on a Unity WebGL project hosted on Netlify
[[headers]]
for = "/Build/*.data.br"
[headers.values]
Content-Encoding = "br"
Content-Type = "application/octet-stream"
[[headers]]
for = "/Build/*.wasm.br"
[headers.values]
Content-Encoding = "br"
@marcusx2
marcusx2 / UnityFreeCamera.cs
Last active February 26, 2024 16:51
Look around camera with mouse - Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FreeCamera : MonoBehaviour
{
public float sensitivity = 10f;
public float maxYAngle = 80f;
private Vector2 currentRotation;
void Update()
@marcusx2
marcusx2 / UnityFlipNormals
Last active September 8, 2020 20:04
Add this to any mesh to flip the normals. Useful to create 360 spheres, etc. Run once and remove the script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FlipNormals : MonoBehaviour {
// Use this for initialization
void Start () {
Mesh mesh = this.GetComponent<MeshFilter>().sharedMesh;
Vector3[] normals = mesh.normals;