Skip to content

Instantly share code, notes, and snippets.

@arvidsson
arvidsson / firebase.js
Last active January 24, 2024 13:24
Firebase Rules
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function signedIn() {
return request.auth != null && request.auth.uid != null;
}
function userExists() {
return exists(/databases/$(database)/documents/users/$(request.auth.uid));

Install

  • Setup firebase project, auth and firestore
  • npx create-react-app <my-app> --template typescript
  • npm install --save react-router-dom
  • npm install -D tailwindcss
  • npx tailwindcss init (https://tailwindcss.com/docs/guides/create-react-app)
  • npm install firebase
  • create firebase config (gcp console)

Commands

Install

  • Install node, npm, npx, expo go (on iphone)
  • npx create-expo-app <app_name> -t expo-template-blank-typescript
  • npx expo install firebase (https://docs.expo.dev/guides/using-firebase/)
  • npx expo customize metro.config.js
  • npm install @react-navigation/native
  • npx expo install react-native-screens react-native-safe-area-context
  • npm install @react-navigation/native-stack

Commands

Install

  • Install python3
  • Install pip
  • Install venv
  • Create virtual env: python3 -m venv venv
  • Source venv: source venv/bin/activate (macos); venv\Scripts\activate.bat (windows)
  • Install django: python -m pip install Django / pip3 install django
  • Create project: django-admin startproject .
  • Create app: python manage.py startapp
  • Create superuser: python manage.py createsuperuser
#define PI 3.14159265359
#define TWOPI 6.28318530718
#define HALF_PI 1.57079632679
float lerp(float a, float b, float t)
{
return (a * (1.0 - t)) + (b * t);
}
// step functions
---
# options: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
# configurator: https://zed0.co.uk/clang-format-configurator/
AccessModifierOffset: '-4'
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: 'true'
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'false'
AlignEscapedNewlines: Left
AlignOperands: 'true'
/*
Hierarchy:
- Game (put EventSystem on the game object)
-- Camera
-- Map
-- Entities
-- Managers?
using System.Collections.Generic;
using UnityEngine;
public class FSMState : MonoBehaviour
{
private void Awake()
{
Setup();
}
/*
* Scaled camera to create illusion of very large objects and parallax movement.
*
* How to use:
* 1. Setup your normal camera:
* - Clear Flags: Depth only
* - Culling Mask: Everything EXCEPT scaled space layer
* - Depth: 1
* 2. Setup your scaled camera:
* - Clear Flags: Skybox
// custom js
document.head.innerHTML += '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">'
// custom css
@media only screen and (max-device-width: 812px) {
div#thread td { display: block; }
td.info { width: 100%; padding: 0 !important; }
td.info div { float: left; }
div.avatar img { width: 40px; height: 40px; }
td.topic { width: 100%; }