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
/* | |
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace | |
so it's better encapsulated. Now you can have multiple random number generators | |
and they won't stomp all over eachother's state. | |
If you want to use this as a substitute for Math.random(), use the random() | |
method like so: | |
var m = new MersenneTwister(); |
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 static org.mockito.Mockito.*; | |
/** | |
* Boostraps a MultipartHttpServletRequest using mockito. | |
* To add a request parameter, define a method called 'parameterName', where request attribute is 'name'. | |
* To add a multipart file, define a method called 'fileName', where the multipart file is called 'name'. | |
* Class is very limited but works as it should providing you use a specific subset of the methods on {@link MultipartHttpServletRequest}. | |
* Subset: | |
* MultipartHttpServletRequest.getParameter | |
* MultipartHttpServletRequest.getFileMap |
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 DartLexer(RegexLexer): | |
""" | |
For `Dart <http://dartlang.org/>`_ source code. | |
""" | |
name = 'Dart' | |
aliases = ['dart'] | |
filenames = ['*.dart'] | |
mimetypes = ['text/x-dart'] |
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('dart:html'); | |
class SVGSamples { | |
void run() { | |
drawlines(); | |
} | |
void drawlines() { | |
final int maxY = 250; |
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
// http://en.wikipedia.org/wiki/Bridge_pattern | |
trait DrawingAPI { | |
def drawCircle(x:Double, y: Double, radius:Double) | |
} | |
class DrawingAPI1 extends DrawingAPI { | |
override def drawCircle(x: Double, y: Double, radius: Double) = { | |
printf("API1.circle at %f:%f radius %f\n", x, y, radius) | |
} |
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('dart:dom', prefix:'dom'); | |
#import('dart:html'); | |
String VERSION = "1"; | |
String TODOS_STORE = 'todos'; | |
initDb(db) { | |
if (VERSION != db.version) { | |
dom.IDBVersionChangeRequest versionChange = db.setVersion(VERSION); | |
versionChange.addEventListener('success', (e) { |
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
/* | |
* dart document.cookie lib | |
* | |
* ported from | |
* http://www.quirksmode.org/js/cookies.html | |
* | |
*/ | |
void createCookie(String name, String value, int days) { | |
String expires; |
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('dart:io'); | |
final String PATH_TO_DARTSDK = "/Users/XYZ/dart-sdk"; | |
final String SUBDIRECTORY = ""; | |
final String LIBRARY_DARTFILE = "XYZ.dart"; | |
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 MyClass{ | |
static MyClass _ref; | |
static MyClass get context() => _ref == null ? new MyClass() : _ref; | |
factory MyClass(){ | |
if (_ref != null) return _ref; | |
_ref = new MyClass._internal(); | |
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('dart:io'); | |
#import('dart:uri'); | |
#import('dart:json'); | |
// Dart Hackathon TLV 2012 | |
// | |
// A simple example to fetch JSON and parse it on the server side | |
// This is a good start for a crawler and/or any other web service | |
// we wish to create using dart on the server side. | |
// |
OlderNewer