Skip to content

Instantly share code, notes, and snippets.

@maxweisel
maxweisel / direct-server-return-test.md
Created August 25, 2020 23:43
Minimal test to verify if direct server return is actually working.

Direct Server Return Test

Summary

According to the Google Cloud documentation and the technical support team, creating a LoadBalancer kubernetes service will create a load balancer with direct server return, and therefore the incoming connection source IP address will be that of the originating client and not the load balancer. However that does not appear to be the case. This is a test kubernetes service + deployment that logs the incoming connection IP in order to validate whether Direct Server Return is working correctly.

Setup

Step 1: Create the service + deployment

@maxweisel
maxweisel / FloatQueue.cs
Created October 29, 2019 23:44
Oculus Platform Microphone Test
#region Copyright & License
/*************************************************************************
*
* The MIT License (MIT)
*
* Copyright (c) 2014 Roman Atachiants ([email protected])
* 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
@maxweisel
maxweisel / gist:cc0bf9a88e5dcec37863c25118aecad8
Created April 4, 2019 19:24
Get the most recent X samples from the Unity microphone
private void Awake() {
_deviceName = "";
_microphone = Microphone.Start(_deviceName, true, 1, frequency);
if (_microphone == null) {
Debug.LogError("Unity returned a null microphone instance :S");
return;
}
_numberOfChannels = _microphone.channels;
_sampleCount = _microphone.samples;
}
@maxweisel
maxweisel / PackingExample.cpp
Created May 6, 2018 05:41 — forked from ananace/PackingExample.cpp
Message packing example for libyojimbo, with built-in compression.
#include <yojimbo.h>
#include <miniz.h>
class PackedMessage : public yojimbo::BlockMessage
{
public:
enum { MsgType = 0x00 };
template <typename Stream>
bool Serialize(Stream& stream)
void TriggerEnded()
{
// Throw the cube by setting the velocity on its rigid body using the rigid body on the empty game object.
Rigidbody rigidBody = _cube.GetComponent<Rigidbody>();
rigidBody.velocity = _controllerRigidBody.GetPointVelocity(_controller.transform.TransformPoint(offset));
rigidBody.angularVelocity = _controllerRigidBody.angularVelocity;
rigidBody.isKinematic = false;
}
void Update() {
/* ... */
SteamVR_Controller.Device device = SteamVR_Controller.Input((int)_trackedObject.index);
// Set our empty game object's rigid body to match the device's velocity and angular velocity.
_controllerRigidBody.velocity = device.velocity;
_controllerRigidBody.angularVelocity = device.angularVelocity;
}
void PositionGeometry(Vector3 position, Quaternion rotation)
{
// Position the empty game object.
_controller.transform.position = position;
_controller.transform.rotation = rotation;
// Position cube to be thrown
_cube.transform.position = position + rotation * offset;
_cube.transform.rotation = rotation;
}
void Awake()
{
/* ... */
// Create an empty game object. Attach a rigid body to use later for calculating velocity.
_controller = new GameObject();
_controllerRigidBody = _controller.AddComponent<Rigidbody>();
_controllerRigidBody.isKinematic = true;
}
// Takes in a linear value from 0-1. Outputs the ease in/out version of it.
float value = linearValue*2.0;
if (value < 1.0) {
value = 0.5 * powf(value, 2.0);
} else {
value = 1.0 - 0.5 * powf(2.0-value, 2.0);
}
return value;
@maxweisel
maxweisel / clickify.js
Created June 28, 2012 23:35
collect.js - use clean urls with Backbone History / Router
(function($){
// Declare the rootUrl used for filtering internal links.
var rootUrl = document.location.protocol + '//' + (document.location.hostname || document.location.host) + (document.location.port ? ':' + document.location.port : '') + '/';
// Helper functions
var getFragment = function(url, root) { // Grab the fragment and format it how Backbone expects
var fragment = url;
if (fragment.indexOf(':') !== -1)
fragment = fragment.replace(/.*:\/\/[^\/]+/, '');
if (!fragment.indexOf(root)) fragment = fragment.substr(root.length);