Skip to content

Instantly share code, notes, and snippets.

View mplacona's full-sized avatar

Marcos Placona mplacona

View GitHub Profile
void snowFall(){
// draw background on canvas
ctx.fillStyle="#000";
ctx.fillRect(0,0,W,H);
//drawing intitial snowflakes on canvas
ctx.fillStyle = "#fff";
// rain
ctx.beginPath();
void main() {
var canvas = querySelector('#stage');
ctx = canvas.getContext('2d');
// resize canvas
canvas.width = W;
canvas.height = H;
// create random flakes
for(int i = 0; i < maxFlakes; i++){
import 'dart:io';
final int port = 5000;
final String address = "127.0.0.1";
void main() {
}
import 'dart:io';
final int port = 5000;
final String address = "127.0.0.1";
void main() {
HttpServer.bind(address, port)
.then((HttpServer server){
});
import 'dart:io';
final int port = 5000;
final String address = "127.0.0.1";
void main() {
HttpServer.bind(address, port)
.then((HttpServer server){
print('listening for connections on $port');
server.listen((HttpRequest request) {
import 'dart:io';
import 'dart:async';
final int port = 5000;
final String address = "127.0.0.1";
void main() {
Future<ServerSocket> serverFuture = ServerSocket.bind(address, port);
serverFuture.then((ServerSocket server) {
print('listening for connections on ' + server.port.toString());
import 'package:unittest/unittest.dart';
import '../bin/factory_pattern.dart';
void main(){
test("new instance of Shape is created", (){
var shape = new IShape();
expect(shape is IShape, isTrue);
});
test("new instance of Rectangle is created", (){
class IShape{
void draw(){}
}
class Rectangle implements IShape{
void draw(){
print("Inside Rectangle::draw() method.");
}
}
class ShapeFactory{
IShape getShape(String shapeType){
// check for nulls being passed
if(shapeType == null){
return null;
}
// check for types
var type = shapeType.toLowerCase();
switch(type){
void main() {
var factory = new ShapeFactory();
var rectangle = factory.getShape('rectangle');
rectangle.draw();
}