Skip to content

Instantly share code, notes, and snippets.

@alvivar
alvivar / latency.txt
Created March 31, 2021 04:14 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
using System;
using BestHTTP.WebSocket;
using UnityEngine;
public class ControllerClient : MonoBehaviour
{
private WebSocket webSocket;
public class Query
{
@alvivar
alvivar / tripsToCvs.js
Created October 8, 2017 19:19
Uber Trips Data
cvs = (function($){
var map = {
pickup: 1,
driver: 2,
fare: 3,
car: 4,
city: 5,
payment_method: 6
};
// Andrés Villalobos ^ andresalvivar@gmail.com ^ twitter.com/matnesis
// 2015/08/11 10:13:43 PM
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Rigidbody2D))]
@alvivar
alvivar / Liteprint.cs
Last active August 29, 2015 14:15
Liteprint: Extension set for a quick & semiautomatic data pool for transform objects.
// Liteprint v0.1 alpha
// Extension set for a quick & semiautomatic data pool for transform objects.
// Just put '.lit' after any transform to access his powers.
// - .litCreate( Prepares & fill a pool for the current transform (optional).
// - .litSpawn( Returns a clone from the pool based on the current transform (Instantiate-like).
// - .litRecycle() Put back the current clone to his pool for reuse.
// - .litFlush() Cleans & destroy all pool elements for the current transform.
// Created by Andrés Villalobos [andresalvivar@gmail.com] [twitter.com/matnesis]
@alvivar
alvivar / GhostGrid.cs
Last active August 29, 2015 14:13
GhostGrid: Lightweight grid component with auto snapping. Just add 'GhostGrid.cs' to any transform to activate the grid for him and his children.
// GhostGrid v0.1 alpha
// Lightweight grid component with auto snapping. Just add 'GhostGrid.cs' to any
// transform to activate the grid for him and his children.
// - ALT + S = Snap all game objects in the grid for the selected transform
// - ALT + A = Enable auto snap in the grid for the selected grid
// - ALT + D = Disable all running grids
@alvivar
alvivar / TeaTime.cs
Last active May 20, 2016 02:22
TeaTime is a fast & simple queue for timed callbacks, focused on solving common coroutines patterns in Unity games.
// @
// TeaTime v0.8.1 beta
// TeaTime is a fast & simple queue for timed callbacks, focused on solving
// common coroutines patterns in Unity games.
// Andrés Villalobos ~ twitter.com/matnesis ~ andresalvivar@gmail.com
// Created 2014/12/26 12:21 am ~ Rewritten 2015/09/15 12:28 pm
@alvivar
alvivar / vermin-reactions.json
Created November 25, 2014 01:51
Vermin Reactions v2
{
"__type": "React.Root",
"target": null,
"notes": "",
"uid": "b84244a7-571e-4199-b50b-91cc9c626a10",
"children": [{
"__type": "React.Selector",
"notes": "",
"uid": "c268c172-b53e-4f7f-820d-d2cbd8982b48",
"children": [{