Skip to content

Instantly share code, notes, and snippets.

View longde123's full-sized avatar
:octocat:
Working from home

paling longde123

:octocat:
Working from home
View GitHub Profile
@lambdalisue
lambdalisue / collision_sector_vs_point.coffee
Created August 29, 2011 04:19
Collision detection of Circular sector vs Point written in CoffeeScript
#!coffee
#
# required
# - vector.coffee - gist: 1177722
#
vector = require './vector'
isCollided = (sector, point) ->
# Collision detection of circular sector and point
toRadian = (d) -> d * Math.PI / 180
@patriknw
patriknw / ClusterRegistrySpec.scala
Last active May 28, 2019 10:58
Example of how to implement a simple cluster wide actor registry.
/**
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.contrib.pattern
import language.postfixOps
import scala.concurrent.duration._
import com.typesafe.config.ConfigFactory
import akka.actor.Actor
/*
Generates a trail that is always facing upwards using the scriptable mesh interface.
vertex colors and uv's are generated similar to the builtin Trail Renderer.
To use it
1. create an empty game object
2. attach this script and a MeshRenderer
3. Then assign a particle material to the mesh renderer
*/
var height = 2.0;
var time = 2.0;
@jimfleming
jimfleming / UnityDiffuseLightmap.shader
Last active June 21, 2023 00:44
Example depicting applying Unity lightmapping data to a simple diffuse shader.
Shader "Diffuse Lightmap" {
Properties {
_MainTex ("Texture 1", 2D) = "white" {}
}
SubShader {
Tags { "RenderType" = "Opaque" }
Pass {
@mstevenson
mstevenson / SaveFBX.cs
Created August 5, 2013 20:05
ASCII FBX file exporter for Unity. Extracted from Michal Mandrysz's Unity Summer of Code 2009 external lightmapping project.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
/*
@m2ym
m2ym / Map.hx
Created August 27, 2013 10:30
Immutable Map implementation using Red-Black Tree in Haxe
private enum Color { Red; Black; }
private enum TreeT<T> {
Leaf;
Node(color: Color, left: TreeT<T>, label: T, right: TreeT<T>);
}
private class TreeF {
private function new() {}
@tkawachi
tkawachi / LambdaOp.hx
Last active May 16, 2018 04:20
Scala like functions for Haxe Option. Now published as http://lib.haxe.org/p/hxopt
import haxe.ds.Option;
using Lambda;
using OptionOp;
class LambdaOp {
public static function flatten<A>(it: Iterable<Option<A>>): Iterable<A> {
return it.filter(function(elem) {
return elem.isDefined();
}).map(function(elem) {
@deltaluca
deltaluca / Main.hx
Created February 18, 2014 08:34
Occlusion culling minecraft 2d
import nape.util.BitmapDebug;
import nape.geom.Vec2;
class Perlin3D {
public static inline function noise(x:Float, y:Float = 0.0, z:Float = 0.0) {
var X:Int = untyped __int__(x); x -= X; X &= 0xff;
var Y:Int = untyped __int__(y); y -= Y; Y &= 0xff;
var Z:Int = untyped __int__(z); z -= Z; Z &= 0xff;
var u = fade(x); var v = fade(y); var w = fade(z);
var A = p(X) +Y; var AA = p(A)+Z; var AB = p(A+1)+Z;
@deandob
deandob / livestream
Created February 26, 2014 22:31
Node.JS function to remux mp4/h.264 video from an IP camera to a HTML5 video tag using FFMPEG
// Live video stream management for HTML5 video. Uses FFMPEG to connect to H.264 camera stream,
// Camera stream is remuxed to a MP4 stream for HTML5 video compatibility and segments are recorded for later playback
var liveStream = function (req, resp) { // handle each client request by instantiating a new FFMPEG instance
// For live streaming, create a fragmented MP4 file with empty moov (no seeking possible).
var reqUrl = url.parse(req.url, true)
var cameraName = typeof reqUrl.pathname === "string" ? reqUrl.pathname.substring(1) : undefined;
if (cameraName) {
try {
cameraName = decodeURIComponent(cameraName);
@jonasmalacofilho
jonasmalacofilho / Mini2.hx
Created April 15, 2014 11:36
Neko client for neko ThreadRemotingServer example
import haxe.remoting.Context;
import haxe.remoting.HttpConnection;
import haxe.remoting.SocketConnection;
import haxe.remoting.SocketProtocol;
import neko.vm.Thread;
import sys.net.Host;
import sys.net.Socket;
import Sys.println;
class Mini2 {