Skip to content

Instantly share code, notes, and snippets.

@jstanden
jstanden / gist:1489447
Last active May 15, 2024 20:47
Simplex Noise in C# for Unity3D - Adapted from James Livingston's MinePackage: http://forum.unity3d.com/threads/minepackage-minecraft-starter-package.69573/
using UnityEngine;
using System.Collections;
public class SimplexNoiseGenerator {
private int[] A = new int[3];
private float s, u, v, w;
private int i, j, k;
private float onethird = 0.333333333f;
private float onesixth = 0.166666667f;
private int[] T;
@kirbysayshi
kirbysayshi / LICENSE
Last active March 19, 2024 07:25
Hierarchical Spatial Hash Grid: extremely efficient spatial hashing for collision detection between objects of any size! This is an implementation in JS as described in http://www10.informatik.uni-erlangen.de/~schornbaum/hierarchical_hash_grids.pdf
Copyright 2012 Andrew Petersen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR O
@lancejpollard
lancejpollard / no.md
Created April 19, 2012 04:46
Meteor scalability issue X

When you start your node server, create 1 LivedataServer.

Say you've defined 10 "subscriptions" via Meteor.subscribe("messages") and some users go to your app.

For each connected user (who connects through web sockets), create a new LivedataSession and store it in memory.

For each LivedataSession, call connect and create a LivedataSubscription for each of the 10 global "subscriptions" you've defined.

@aras-p
aras-p / ImportMeshUtility.cpp
Created May 31, 2012 15:01
Unity tangent space calculation
// THIS IS ONLY A PORTION OF THE FILE
// WILL NOT COMPILE OUT OF THE BOX!
void OrthogonalizeTangent (TangentInfo& tangentInfo, Vector3f normalf, Vector4f& outputTangent)
{
TangentInfo::Vector3d normal = { normalf.x, normalf.y, normalf.z };
TangentInfo::Vector3d tangent = tangentInfo.tangent;
TangentInfo::Vector3d binormal = tangentInfo.binormal;
@onyxraven
onyxraven / rds.sh
Last active June 21, 2022 13:42 — forked from douglasjarquin/gist:2208690
Amazon RDS Performance Tuning Settings
#XLarge DBInstanceClassMemory = 15892177440 = 14.8GB
#/32 = 496630545 = 473MB
#/64 = 248315272 = 236MB
#/128 = 124157636 = 118MB
#/256 = 62078818 = 59MB
#/512 = 31039409 = 29MB
#/12582880 = 1263 #default same divisor as max_connections = 4041.6MB = 4237924762
#/25165760 = 623 # half of max_connections = 1993.6MB
#/50331520 = 315 # quarter of max_connections = 1008MB = 1056964608
#*(3/4) #default innodb pool size = 11922309120
14:02 * josephg reads up
14:03 < josephg> koppor, rawtaz: ShareJS does all the actual OT
14:03 < josephg> racer is now a wrapper around it which does things like refs, reflists
14:03 < josephg> ... it manages subscriptions for you (so if you change pages, you don't have to manually unsubscribe)
14:03 < josephg> stuff like that.
14:03 < josephg> ShareJS just does the document editing.
14:04 < josephg> Redis is currently important for 3 things:
14:05 < josephg> - We need to be able to atomically append to the op log. We're using redis's lua scripting to do atomic commits
14:05 < josephg> - Redis is also used for pubsub between your backend servers
14:05 < josephg> (well, between your servers)
@MaerF0x0
MaerF0x0 / gist:7242600
Created October 31, 2013 00:22
Meteor publish and approximate SQL
Meteor.publish(
'scores',
function() {
return Scores.find(
{score:{$gt:100}},
{
fields: {user:1,score:1},
sort:{score:-1},
limit:10,
skip:pageNumber*pageSize
@chfritz
chfritz / simpleFileDragAndDrop.js
Last active May 29, 2019 21:29
HTML5: simple file drag&drop (without upload).
/*
(MIT License)
Copyright (c) 2012 Christian Fritz
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
@stramit
stramit / InputField.cs
Last active January 14, 2020 14:17
uGUI InputField (rc1)
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;
namespace UnityEngine.UI
{
import java.util.Arrays;
import java.util.HashSet;
public class BlockStorage {
private static final int DATA_SHIFT = 12;
private static final int EMITTEDLIGHT_SHIFT = DATA_SHIFT + 4;
private static final int SKYLIGHT_SHIFT = EMITTEDLIGHT_SHIFT + 4;
private static final int EMPTY_ENTRY = -1;
private byte[] index = new byte[2048];