Skip to content

Instantly share code, notes, and snippets.

View coastwise's full-sized avatar

Patrick McKenna coastwise

  • Mississauga, Ontario, Canada
View GitHub Profile
@coastwise
coastwise / VertMinusCameraFOV.cs
Created July 8, 2013 20:16
VERT- Field of view scaling for Unity3D cameras.
using UnityEngine;
using System.Collections;
/**
* This class attempts to force VERT- Field of view scaling.
* By default, Unity uses the HOR+ technique.
*
* http://en.wikipedia.org/wiki/Field_of_view_in_video_games#Scaling_methods
*/
@coastwise
coastwise / gist:5951291
Created July 8, 2013 18:33
Compute horizontal field of view in Unity
float vFOVInRads = Camera.main.fieldOfView * Mathf.Deg2Rad;
float hFOVInRads = 2 * Mathf.Atan( Mathf.Tan(vFOVInRads / 2) * Camera.main.aspect);
float hFOV = hFOVInRads * Mathf.Rad2Deg;
@coastwise
coastwise / Bcrypt.php
Created June 11, 2012 13:58
Simple PHP 5.3+ Bcrypt class
<?php
/*
By Marco Arment <me@marco.org>.
This code is released in the public domain.
THERE IS ABSOLUTELY NO WARRANTY.
*/
class Bcrypt {
@coastwise
coastwise / gist:2725710
Created May 18, 2012 14:57
Codeception vs PHPUnit

We are testing a simple controller from imaginable MVC framework.

<?php
class UserController extends AbtractController {

    public function show($id)
    {
        $user = $this->db->find('users',$id);
        if (!$user) return $this->render404('User not found');
@coastwise
coastwise / vtable_example.c
Created June 17, 2011 16:55
one way to implement vtables in C
/* Original Author: Tom Gunn
* http://www.daniweb.com/software-development/c/threads/228277
*/
#include <stdio.h>
/* class definitions */
typedef struct Base
{
void (**vtable)();