Skip to content

Instantly share code, notes, and snippets.

@iggymacd
iggymacd / SudokuBoardPresenter .dart
Created January 22, 2012 01:31
Partial Code demonstrating scope
class SudokuBoardPresenter {
TableCellElement activeElement;
SudokuBoard _currentBoard;
SudokuBoardPresenter(SudokuBoard currentBoard){
_currentBoard = currentBoard;
}
TableElement renderSuduokuBoard(){
//render grids first
List<SudokuCell> allCells = _currentBoard.allCells;
#import('dart:io');
void main() {
List<int> data = [0x00, 0x01, 0x10, 0x11, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff];
ListInputStream stream = new ListInputStream();
int count = 0;
ReceivePort donePort = new ReceivePort();
stream.write(data);
void onData() {
print('bytes available on stream is ' + stream.available());
void parse(HTTPRequest req, var cb){
if(_testingHandler != null){
_testingHandler(data);
return;
}
writeHeaders(req.headers);
_callBack = cb;
print('parsing data');
//_callBack();
req.dataReceived = dataReceivedHandler;
@iggymacd
iggymacd / playground.dart
Created March 9, 2012 17:23
Dart sample click simulation
#import("dart:html");
void main() {
document.query('#button').on.click.add( (e)
{
document.query('#result').innerHTML="clicked!";
});
MouseEvent e = new MouseEvent( 'click', window, 0,0,0,0,0,0,
canBubble:true, cancelable:true,
#import('dart:isolate', prefix:'isolate');
List split(List numbers) {
int size = numbers.length;
int middleIndex = (size/2).floor().toInt();
var list1 = numbers.getRange(0, middleIndex);
var list2 = numbers.getRange(middleIndex, size-middleIndex);
return [list1, list2];
}
import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang.exception.ExceptionUtils;
import com.mitratech.teamconnect.base.BQGroupAccess;
import com.mitratech.teamconnect.base.YQGroup;
import com.mitratech.teamconnect.base.factory.GQGrupStore;
import com.mitratech.teamconnect.entity.BNEnterpriseObject;
import com.mitratech.teamconnect.entity.BNGroupAccess;
@iggymacd
iggymacd / FileHandler.dart
Created April 30, 2012 18:39
Sample FileHandler
class FileHandler {
FileHandler(){
}
void onRequest(HttpRequest request, HttpResponse response, [String fileName = null]){
final int BUFFER_SIZE = 4096;
if (fileName == null) {
fileName = request.path.substring(1);
}
@iggymacd
iggymacd / NotFoundHandler.dart
Created April 30, 2012 18:40
Sample NotFound Handler
class NotFoundHandler {
NotFoundHandler(){
}
List<int> _notFoundPage;
static final String notFoundPageHtml = """
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
#import('../ThirdParty/dartwatch-JsonObject/JsonObject.dart');
class Stooge extends JsonObject{
Stooge(this.name, this.addresses);
List<Address> addresses;
String name;
}
class Address extends JsonObject{
Address(this.city);
String city;
#import('../ThirdParty/dartwatch-JsonObject/JsonObject.dart');
class Stooge extends JsonObject{
Stooge(name, addresses):super(){
this.name = name;
this.addresses = addresses;
}
//List<Address> addresses;
//String name;
}