Skip to content

Instantly share code, notes, and snippets.

View gsimard's full-sized avatar

Guillaume Simard gsimard

View GitHub Profile
Public Function nbrVoituresSurCercle(ByVal i As Long) As Long
nbrVoituresSurCercle = i
End Function
Public Function nbrVoituresTotal(ByVal i As Long) As Long
If i = 1 Then
nbrVoituresTotal = nbrVoituresSurCercle(1)
Else
nbrVoituresTotal = nbrVoituresSurCercle(i) + nbrVoituresTotal(i - 1)
End If
@gsimard
gsimard / option.js
Last active August 29, 2015 14:18 — forked from igstan/option.js
// `unit` is `return` from Haskell
// `bind` is `>>=` from Haskell, or `flatMap` from Scala
var None = {
bind: function (fn) { return this; },
unit: function (v) { return Option(v); },
getOrElse: function (elseValue) { return elseValue; }
};
var Some = function (value) {
import akka.actor.ActorRef
/**
* Handle global reference to actor
*
* Usage:
* object MyGlobal extends GlobalActorRef(Actor.registry.actorFor[MyActor])
* object MyGlobal extends GlobalActorRef(Some(Actor.remove.actorFor[MyActor]))
*
* @author teamon
@gsimard
gsimard / gist:2407867
Created April 17, 2012 18:02
Problem creating get function for custom Octave object
## octave --version
## GNU Octave, version 3.6.1
## file: @triangle/triangle.m
function t = triangle (p1, p2, p3)
if (nargin == 3)
if (isvector(p1) && isreal(p1) && length(p1) == 3 &&
isvector(p2) && isreal(p2) && length(p2) == 3 &&
@gsimard
gsimard / gist:2267395
Created March 31, 2012 18:29
Sandbox multithread problem ?
;; Sandbox
(def ^:dynamic *sb* nil)
(defn make-sb []
(def ^:dynamic *sb* (sandbox (conj secure-tester-without-def :timeout 2000))
;; Define some functions within the sandbox
(*sb* '(defn jump [] (str "JUMP"))))
;; Swank
(def ^:dynamic *swank* nil)
(defn -startSwank []
@gsimard
gsimard / gist:2223372
Created March 28, 2012 03:38
Clojail security problem
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.simontuffs.onejar.Boot.run(Boot.java:340)
at com.simontuffs.onejar.Boot.main(Boot.java:166)
Caused by: java.util.concurrent.ExecutionException: java.security.AccessControlException: access denied (java.lang.RuntimePermission setContextClassLoader), compiling:(NO_SOURCE_PATH:0)
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:232)
at java.util.concurrent.FutureTask.get(FutureTask.java:91)
@gsimard
gsimard / gist:2199626
Created March 25, 2012 20:44
Clojail invokation error
In clojail.clj:
(ns ca.gsimard.spacecraft.client.clojail
(:use [clojail core testers])
(:gen-class
:name ca.gsimard.spacecraft.client.clojail
:methods [#^{:static true} [epadEval [String] String]
#^{:static true} [getAction [] String]]))
In main.java:
@gsimard
gsimard / gist:2065481
Created March 17, 2012 21:34
More functional way of doing that
var entitiesMap = Map[Int,Entity]()
private val randEntityId = new scala.util.Random(0)
def uniqueEntityId() = {
var id = 0;
do {
id = randEntityId.nextInt()
} while (entitiesMap.contains(id))
@gsimard
gsimard / cube.scala
Created March 17, 2012 01:17
Int(32) required: Array[Int]
class Cube(val size: Float = 1.0f, var pos: Vector3 = Vector3(0f, 0f, 0f), val texture: Array[Int] = Array(32,32,32,32,32,32)) {
def this(size: Float, pos: Vector3, texture: Int = 32) = this(size,pos,Array(texture,texture,texture,texture,texture,texture))
}
Description Resource Path Location Type
type mismatch; found : Int(32) required: Array[Int] Error occurred in an application involving default arguments.
@gsimard
gsimard / PongAkka.scala and others
Created March 13, 2012 19:29
Akka + remote Actor => println not working ?
// application.conf
server {
akka {
actor {
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
transport = "akka.remote.netty.NettyRemoteTransport"
netty {
hostname = "127.0.0.1"