Skip to content

Instantly share code, notes, and snippets.

@ciscoheat
ciscoheat / gist:3004119
Created June 27, 2012 13:40
Classes for mocking HttpContext in ASP.NET MVC with Moq.
using System.Collections.Generic;
using System.Security.Principal;
using System.Web;
using Moq;
namespace Tests.Utils
{
public class HttpContextMock
{
public HttpContextMock(IEnumerable<KeyValuePair<string, string>> requestParams)
// The following will be macromagically transformed...
class LazyExample implements Lazy
{
var values:Array<Int>;
public function new()
{
this.values = [3, 5, 1, 7];
}
@ciscoheat
ciscoheat / install-haxe.sh
Last active August 29, 2015 14:02
Patched Haxe 3.1.3 install script, until it's fixed on OpenFL site.
#!/bin/sh
# Patched version for installing Haxe on Linux.
HAXE_VERSION=3.1.3
HAXE_VERSION_COMMA=3,1,3
NEKO_VERSION=2.0.0
if [ "$1" = "y" -o "$1" = "-y" ]; then
@ciscoheat
ciscoheat / Vagrantfile
Last active May 21, 2016 01:45
Vagrant setup for c5
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
@ciscoheat
ciscoheat / Vagrantfile
Last active December 21, 2015 14:10
Vagrant setup for Haxe
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
@ciscoheat
ciscoheat / Example.js
Last active August 29, 2015 14:13
Brainstorming a simple API description format, generic but with Haxe externs in mind
// The format is JSON, but using js for comments.
{
// Type (Starts with Uppercase to differentiate from the primitive types)
"IncomingForm": {
"" : "Empty key leaves room for a description.",
// A function ends with (). Array value signifies overloading
"parse()": [{
"" : "Parse a form",
// Parameter: Type
"req": "js.npm.express.Request",
@ciscoheat
ciscoheat / Attraction.hx
Created January 12, 2015 05:55
Problem with creating a Mongoose model
package;
import js.npm.mongoose.macro.Manager;
import js.npm.mongoose.macro.Model;
typedef AttractionSchema = {
name: String,
description: String,
location: { lat: Float, lng: Float },
history: {
@ciscoheat
ciscoheat / Example.hx
Last active August 29, 2015 14:14 — forked from cambiata/Example.hx
Using a View instead of a Module
class User implements Model {
@prop public var name : String;
public function new(name) {
this.name = M.prop(name);
}
}
class TestModule implements View {
var user:User;
@ciscoheat
ciscoheat / Main.hx
Last active August 29, 2015 14:21
Minimal working DCI example for Haxe
/*
How to run:
1. Download and install Haxe: http://haxe.org/download/
2. Save this code to Main.hx and open a command prompt in the same directory
3. Execute "haxelib install haxedci"
4. Execute "haxe -main Main -lib haxedci --interp"
For javascript output:
haxe -main Main -lib haxedci -js moneytransfer.js
*/
import js.Browser;
import mithril.M;
class App implements Mithril {
public static function main() {
M.mount(Browser.document.body, new App());
}
var tests = [];