Skip to content

Instantly share code, notes, and snippets.

View japsuu's full-sized avatar

Jasper Honkasalo japsuu

View GitHub Profile
@GrabYourPitchforks
GrabYourPitchforks / memory_guidelines.md
Last active May 29, 2024 11:04
Memory usage guidelines

Memory<T> usage guidelines

This document describes the relationship between Memory<T> and its related classes (MemoryPool<T>, IMemoryOwner<T>, etc.). It also describes best practices when accepting Memory<T> instances in public API surface. Following these guidelines will help developers write clear, bug-free code.

First, a tour of the basic exchange types

  • Span<T> is the basic exchange type that represents contiguous buffers. These buffers may be backed by managed memory (such as T[] or System.String). They may also be backed by unmanaged memory (such as via stackalloc or a raw void*). The Span<T> type is not heapable, meaning that it cannot appear as a field in classes, and it cannot be used across yield or await boundaries.

  • Memory is a wrapper around an object that can generate a Span. For instance, Memory instances can be backed by T[], System.String (readonly), and even SafeHandle instances. Memory cannot be backed by "transient" unmanaged me

@Nordaj
Nordaj / Deformable.cs
Created May 16, 2019 01:03
Runtime mesh deformation on impact script for Unity.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Deformable : MonoBehaviour
{
//Public
public float minImpulse = 2;
public float malleability = 0.05f;
public float radius = 0.1f;
@AnatomicJC
AnatomicJC / android-backup-apk-and-datas.md
Last active July 18, 2024 22:51
Backup android app, data included, no root needed, with adb

Backup android app, data included, no root needed, with adb

Note: This gist may be outdated, thanks to all contributors in comments.

adb is the Android CLI tool with which you can interact with your android device, from your PC

You must enable developer mode (tap 7 times on the build version in parameters) and install adb on your PC.

Don't hesitate to read comments, there is useful tips, thanks guys for this !

@brihernandez
brihernandez / FreelancerShipPhysics.cs
Last active August 11, 2023 03:51
Freelancer ship physics for Unity. Includes engine kill and thruster.
// ====================================================================================================
// In my codebase, all ships have their own instance of this that they use to apply physics with.
// I'm using a struct mostly because I want to maintain copy semantics.
// ====================================================================================================
public struct FlightInput
{
public float Pitch;
public float Yaw;
public float Roll;
using System;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UnityEngine.Tilemaps
{
/// <summary>
/// Terrain Tiles, similar to Pipeline Tiles, are tiles which take into consideration its orthogonal and diagonal neighboring tiles and displays a sprite depending on whether the neighboring tile is the same tile.