This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Person = (function() { | |
// private statics | |
var greetHeader = "Welcome,"; | |
var greetFooter = "! Have a nice day!"; | |
// constructor -- define instance specific stuff | |
function Person(isMale, firstName, lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* see Boeffi's tutorial: http://boeffi.net/tutorials/local-mock-variables-ein-dritter-weg-in-jmockit/ | |
* | |
* useful for abstract classes / interfaces (shorter than implementing all methods for a "dummy" instance which is dynamically partially mocked afterwards; cleaner than static partial mocking) | |
* take a look at dynamic partial mocking for mocking concrete classes: | |
* http ://jmockit.googlecode.com/svn/trunk/www/tutorial/BehaviorBasedTesting.html#dynamicPartial | |
*/ | |
public final class DatabaseTest { | |
public interface IUser {} | |
public interface IPassword {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See http://stackoverflow.com/q/750486 for details | |
var callbacksIncorrectValue = []; | |
var callbacksCorrectValue = []; | |
var callbacksReference = []; | |
var array = ["A", "B", "C"]; | |
for (var i = 0; i < array.length; ++i) { | |
var element = array[i]; | |
callbacksReference.push(function() { return array[i] }); | |
callbacksIncorrectValue.push(function() { return element }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.mahout.cf.taste.common.NoSuchItemException; | |
import org.apache.mahout.cf.taste.common.Refreshable; | |
import org.apache.mahout.cf.taste.common.TasteException; | |
import org.apache.mahout.cf.taste.impl.common.FastIDSet; | |
import org.apache.mahout.cf.taste.impl.common.LongPrimitiveArrayIterator; | |
import org.apache.mahout.cf.taste.impl.common.LongPrimitiveIterator; | |
import org.apache.mahout.cf.taste.impl.model.GenericUserPreferenceArray; | |
import org.apache.mahout.cf.taste.model.DataModel; | |
import org.apache.mahout.cf.taste.model.PreferenceArray; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Platform; | |
import javafx.embed.swing.JFXPanel; | |
import javafx.scene.Group; | |
import javafx.scene.Scene; | |
import javax.swing.*; | |
/** | |
* A custom {@link java.applet.Applet Applet} that sets-up a JavaFX environment. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object FilterTypes extends App { | |
import scala.reflect.ClassTag | |
import scala.reflect.runtime.universe._ | |
object RichClass { | |
def unapply[T](a: RichClass[T]): Option[T] = Option(a.value) | |
} | |
implicit class RichClass[T](val value: T)(implicit val classTag: ClassTag[T], val typeTag: TypeTag[T]) {} | |
def getOfType[T : ClassTag : TypeTag](list: Seq[RichClass[_]]): Seq[T] = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* DEMO should display particles below the moving platform, but does not, as the current viewport._scale is not | |
* considered when displaying particles. | |
* See https://github.com/craftyjs/Crafty/pull/881 | |
*/ | |
var Crafty = require('craftyjs'); | |
Crafty.init(600, 300); | |
Crafty.background('rgb(127,127,127)'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.jbox2d.checksum; | |
import org.jbox2d.collision.shapes.PolygonShape; | |
import org.jbox2d.common.Settings; | |
import org.jbox2d.common.Vec2; | |
import org.jbox2d.dynamics.*; | |
import java.util.concurrent.ScheduledThreadPoolExecutor; | |
import java.util.concurrent.TimeUnit; | |
import java.util.concurrent.atomic.AtomicInteger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Crafty = require('craftyjs'); | |
Crafty.init(800, 600); | |
Crafty.background('black'); | |
/** | |
* Chaser Component. Automatically chases entity given speed. | |
*/ | |
Crafty.c("Chaser", { | |
required: "2D", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright Daniel Berger | |
// see https://groups.google.com/forum/#!topic/craftyjs/1oOwQrcCd-4 | |
var Crafty = require('craftyjs'); | |
Crafty.init(960, 660); | |
var computeSpeed = function() { | |
return 500 + (500 ^ 2 * (((((Floor.y / player.y) ^ 2 + 2 + (player.y / Floor.y) ^ 2) ^ 0.5) * Floor.y * player.y) ^ 0.5) / (((((Floor.x / player.x) ^ 2 + 2 + (player.x / Floor.x) ^ 2) ^ 0.5) * Floor.x * player.x) ^ 0.5)) ^ 0.5 | |
}; |
OlderNewer