Skip to content

Instantly share code, notes, and snippets.

View mitsuoka's full-sized avatar

Teruyoshi Mitsuoka mitsuoka

  • Chigasaki, Japan
View GitHub Profile
@mitsuoka
mitsuoka / index.html
Last active March 13, 2019 11:28
canvas_test : Sample code for DartPad embedding
<html>
<head>
<title>CanvasTest</title>
</head>
<body>
<h1>CanvasTest</h1>
<h2 id="status">dart is not running</h2>
<script defer src="Canvas_Test.dart.js"></script>
<canvas id="canvas" width="200" height="200"></canvas>
</body>
@mitsuoka
mitsuoka / HttpSessionTestServer.dart
Last active September 8, 2018 10:27
Dart HTTP servers utilizing HttpSession abstract class
/*
Dart code sample : Simple HttpSession test server.
Note: Do not use this code for actual applications.
Usage:
1) Run this HttpSessionTest.dart as server.
2) Access this server from your browser : http://localhost:8080/SessionTest
Ref: www.cresc.co.jp/tech/java/Google_Dart/DartLanguageGuide.pdf (in Japanese)
November 2012, by Cresc Corp.
January 2013, incorporated API change
February 2013, incorporated API cange (Date -> DateTime)
@mitsuoka
mitsuoka / IsolateTestFibonacci.dart
Last active October 7, 2015 03:58
Dart code sample: Isolate concurrency tests using Fibonacci function
/*
* Dart code sample for concurrency tests.
* Evaluate performances in the following cases:
* 1) Only the parent computes fib() Fibonacci function (comment out lines 40 and 41)
* 2) Parent uses fib() and the child uses fibo() function (comment out line 41)
* 2) Parent and child share the same fib() function (comment out line 40)
* Tested on Dartium.
* Place dart.js bootstrup code in the packages/browser holder
* July 2012, by Cresc corp.
* October 2012, incorporated M1 changes.
@mitsuoka
mitsuoka / MIME.dart
Last active November 11, 2022 12:43
Dart WebSocket chat server and client samples
library MIME;
// get MIME type (returns null if there is no such extension)
String mimeType(String extension) => _mimeMaps[extension];
// default MIME type mappings
Map _mimeMaps = const {
'abs': 'audio/x-mpeg',
'ai': 'application/postscript',
'aif': 'audio/x-aiff',
@mitsuoka
mitsuoka / HttpSessionManager.dart
Last active October 6, 2015 05:07
Cookie based HTTP session manager library and its sample applications
/*
*** Cookie based HTTP session manager library ***
This is a third party session manager developed before the HttpSession was added
to dart:io on October 30th. See: http://code.google.com/p/dart/issues/detail?id=3258.
Functions and methods in this library are almost equivalent to those of Java Sevlet.
Note: Under evaluation. Do not use this code for actual applications.
Applications should not use response.headers.set("Set-Cookie", someString);
Instard, use the setCookieParameter method.
Available functions and methods:
Session getSession(HttpRequest request, HttpResponse response)
@mitsuoka
mitsuoka / Client.html
Last active November 28, 2022 15:03
Dart code sample: Simple file server and MIME type library
<!DOCTYPE html>
<html>
<head>
<title>Request a File</title>
</head>
<body>
<h1>Request a file</h1>
<h2>Enter the file name to download</h2>
<!-- Modify following lines for your application -->
<form method="get" action="http://localhost:8080/fserver">
@mitsuoka
mitsuoka / StatusLineTest.dart
Last active October 4, 2015 15:18
Dart code sample : Status line setting and HTTP response
// Dart code sample : Status line setting and HTTP response
// Returns a response with required status line
// 1. Create a folder named StatusLineTest
// 2. Put StatusLineTest.dart and StatusLineTest.html into the folder
// 3. From Dart editor, File -> Open Folder, and select the StatusLineTest folder
// 4. Run StatusLineTest.dart as server
// 5. Access file:///c:/..../StatusLineTest/StatusLineTest.html from your browser
// 6. Select a status code and test response of available browsers
// Ref: www.cresc.co.jp/tech/java/Google_Dart/DartLanguageGuide.pdf (in Japanese)
// May 2012, by Cresc Corp.
@mitsuoka
mitsuoka / DumpHttpRequest.dart
Last active October 4, 2015 14:28
Dart HTTP server code sample : Returns available information from the request.
/*
Dart code sample : Simple tool for HTTP server development
Returns contents of the HTTP request to the client
1. Save these files into a folder named DumpHttpRequest.
2. From Dart editor, File > Open Folder and select this DumpHttpRequest folder.
3. Run DumpHttpRequest.dart as server.
4. Access the DumpHttpRequest.html file from your browser such as : file:///C:/ … /DumpHttpRequest/DumpHttpRequest.html
5. Enter some text to the text areas and click “Submit using POST” or “Submit using GET” button.
6. This server will return available data from the request. This data is also available on the Dart editor’s console.
Ref: www.cresc.co.jp/tech/java/Google_Dart/DartLanguageGuide.pdf (in Japanese)
@mitsuoka
mitsuoka / TimerIsolateLibrary.dart
Last active September 25, 2022 21:04
Dart code sample of a precision timer isolate.
/*
Dart code sample : Timer Isolate
Function timerIsolate provides your application with accurate timings with
+/- few mS accuracy depending on your pc's performance.
note : Windows Vista, Windows Server 2008, Windows 7 or later required for this code.
To try this sample:
1. Put these codes into the holder named TimerIsolateSample.
@mitsuoka
mitsuoka / IsolateTest.dart
Last active October 4, 2015 14:18
Dart code sample for establishing communications link between isolates
// Dart code sample for establishing communications link between isolates
// Tested on Dartium
// Source : www.cresc.co.jp/tech/java/Google_Dart/DartLanguageGuide.pdf (in Japanese)
// March 2012, by Cresc corp.
// October 2012, incorporated M1 changes
// January 2013, incorporated API changes
// February 2013, incorporated API changes
import 'dart:html';
import 'dart:async';