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
// Fox | |
foxImg = file.loadImage("fox.png") | |
fox = new Sprite | |
fox.image = foxImg | |
fox.localBounds = new Bounds | |
fox.localBounds.width = foxImg.width | |
fox.localBounds.height = foxImg.height |
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
// Animation class | |
// It can animate a Sprite from its current position to | |
// a target position in the desired amount of time, in a | |
// series of steps. | |
// | |
// This last point is important, since it means other things | |
// can happen at the same time while animating (e.g. processing | |
// user input, animating other sprites, etc.) |
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
st = time | |
result = 0 | |
counter = 0 | |
while counter < 3000000 | |
result = (result + rnd) / 2 | |
counter = counter + 1 | |
end while | |
print result |
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 "stringUtil" | |
// Renders the given text on the given display in the | |
// given text size ("small"/"normal"/"large") starting | |
// at x=left, y=top up to a maximum of "maxWidth" pixels, | |
// wrapping to a next line if necessary | |
TextRenderer = {} | |
TextRenderer.display = null | |
TextRenderer.left = -1 | |
TextRenderer.top = -1 |
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
canvasWidth = 50 | |
canvasHeight = 50 | |
scale = 10 | |
speed = 0.2 | |
colorToRgb = function(value) | |
return color.rgb(255, | |
255 * cos(value * pi), | |
255 * sin(value * pi)) | |
end function |
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
// We need this for list.any, list.contains, list.remove ... | |
import "listUtil" | |
countRows=4 | |
countCols=5 | |
// How long can you look at cards before hiding them again | |
// In seconds | |
SECONDS_TO_PEEK=1 |
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
val jsonStrToSend = "" | |
val serverUrl = "" | |
def handleAjaxError(jqXHR: JQueryXHR, textStatus: String, errorThrow: String): Unit = { | |
println("Error while performing AJAX POST") | |
} | |
def handleAjaxSuccess(data: js.Any, textStatus: String, jqXHR: JQueryXHR): Unit = { | |
val jsonFromServer = jqXHR.responseText | |
println(s"Got from server: $jsonFromServer") |
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
class Event { | |
} | |
class SomeComponent { | |
// Q: How to express the type of _callback? | |
var _callback = (Event e) { /* dummy implementation */}; |
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 scala.util.Random | |
/** | |
* @author Sebastian Nozzi | |
*/ | |
object RaffleApp extends App with HelperMethods { | |
lazy val numberCandidates: Set[Int] = { | |
val allNumbers = (1 to 17).toSet | |
val numbersThatWonSomething = Set[Int]() |
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.scalavienna.refactoringdojo.gameoflife | |
case class Pos(col: Int, row: Int) { | |
def +(other: Pos): Pos = Pos(col + other.col, row + other.row) | |
} | |
case class Board(liveCells: Seq[Pos], size: Int) { | |
def isLiveCell(p: Pos) = liveCells.contains(p) | |
def nextIteration = BoardCalculator.nextIteration(this) |
NewerOlder