Skip to content

Instantly share code, notes, and snippets.

@neildanson
neildanson / structures.fs
Created November 6, 2012 22:06
Type declarations
type Ray(position : Vector3D, direction:Vector3D) =
member ray.Position = position
member ray.Direction = direction
@neildanson
neildanson / ray.cs
Created November 6, 2012 22:12
Declaring types
class Ray
{
private readonly Vector3D position;
private readonly Vector3D direction;
public Ray(Vector3D position, Vector3D direction)
{
this.position = position;
this.direction = direction;
}
@neildanson
neildanson / Effects.fx
Created August 31, 2013 20:11
Example fx file that compiles and runs fine on Windows, iOS & Android.
float fTimer;
float fPixellateFactor = 1.0f;
sampler ColorMapSampler : register(s0);
float4 NormalShader(float2 Tex:TEXCOORD0) : COLOR
{
float4 color = tex2D(ColorMapSampler, Tex);
return color;
}
namespace FSharpTracer
open System
type Vector =
{ X : float
Y : float
Z : float }
member v.Dot(v1 : Vector) = (v.X * v1.X) + (v.Y * v1.Y) + (v.Z * v1.Z)
member v.Length() = sqrt (v.Dot v)
#pragma once
#include <math.h>
class Vector
{
const double x, y, z;
public:
Vector(double x, double y, double z);
double Dot(Vector);
double Length();
#include "Vector.h"
Vector::Vector(double px, double py, double pz) : x(px), y(py), z(pz) {
}
double Vector::Dot(Vector v) {
return (this->x * v.x) + (this->y * v.y) + (this->z * v.z);
}
double Vector::Length(){
package types
import "math"
type Vector struct {
X, Y, Z float64
}
func (v Vector) Dot(v1 Vector) float64 {
return (v.X * v1.X) + (v.Y * v1.Y) + (v.Z * v1.Z)
use std::num;
pub struct Vector {
pub x: f64,
pub y: f64,
pub z: f64
}
impl Vector {
pub fn dot(&self, v:Vector) -> f64 {
import Foundation
class Vector {
let x,y,z: Double;
init(x:Double, y:Double, z:Double) {
self.x = x;
self.y = y;
self.z = z;
}
@neildanson
neildanson / XdesProcKiller.fsx
Last active August 29, 2015 14:26
F# Script for periodically killing the pesky XDesProc.exe that often hangs Visual Studio for no good reason
open System
open System.Diagnostics
printfn "XDesProc killer"
printfn "Press Return to Close"
printfn "======================"
let rec killer() = async {
let xdesproc = Process.GetProcessesByName "xdesproc"