Thursday, 25 June 2015

Dart SDK 1.11.0 Chocolatey Packages for Windows

Chocolatey is a package manager for Windows similar to Linux's apt-get, based on Microsoft's Nuget tool and Powershell scripting language. It works from the command-line and from a WPF GUI interface.

Chocolatey still has a large moderation backlog - however you can install unmoderated versions by specifiying it at the install.

Command line installation:

choco uninstall dart-sdk

choco install -y dart-sdk  -version 1.11.0
To verify you have the right version on your path.
dart --version

Dart VM version: 1.11.0 (Wed Jun 24 06:44:48 2015) on "windows_x64"

Wednesday, 24 June 2015

Dart POW - ( Package Of The Week) #9 : dart_feed

Who is ready for another - Dart POW? A weekly look at an interesting Package on pub.dartlang.org

dart_feed is a simple RSS 2.0 feed reader library. It is pretty easy to use - here's my simplified version of one of the examples.

library DartFeed.example;

import 'dart:io';
import 'package:dart_feed/dart_feed.dart';

List webFeeds = [
  "http://divingintodart.blogspot.com/feeds/posts/default?alt=rss"
];

main() {
  
  FeedParser parser = new FeedParser();
  parser.stream.listen(printFeed);
  
  for (var feed in webFeeds) {
    parser.fromUri(Uri.parse(feed));
  }
}

void printFeed(Feed feed) {
  print(feed.title);
  for (var item in feed.items) {
    stdout.write("\t ${item.title}");
    if (item.title == "") print(item.description);
    else print("");
  }
}

Feel free to leave a comment with suggestions for the next Dart POW post! Don't be too shy to suggest your own package :-)

Monday, 22 June 2015

Get 80% off a Book from Packt including Dart titles

Here's a way to pick up a Dart or other book at a discount but move fast! Packt Publishing are running a 'Skill Up Survey' to keep in touch with the development community. Check out their selection of Dart books.

In return, you will receive an 80% discount on your next Packt purchase and the survey results will be shared in July!

Thursday, 18 June 2015

Dart POW - ( Package Of The Week) #8 : rpi_gpio

Who is ready for another - Dart POW? A weekly look at an interesting Package on pub.dartlang.org

rpi_gpio is a Dart library for accessing the Raspberry Pi GPIO pins.

Code snippet:

...
main() async {
  Gpio.hardware = new RpiHardware();
  var gpio = Gpio.instance;
  var pin = gpio.pin(1, output);
  for (int count = 0; count < 5; ++count) {
    pin.value = 1;
    await _delay(1000);
    pin.value = 0;
    await _delay(1000);
  }
}
...

Feel free to leave a comment with suggestions for the next Dart POW post! Don't be too shy to suggest your own package :-)

Friday, 12 June 2015

Chocolatey Dart SDK Packages for Windows 1.10.1

Chocolatey is a package manager for Windows similar to Linux's apt-get, based on Microsoft's Nuget tool and Powershell scripting language. It works from the command-line and from a WPF GUI interface.

Chocolatey still has a large moderation backlog - however you can install unmoderated versions by specifiying it at the install.

Command line installation:

choco uninstall dart-sdk

choco install -y dart-sdk  -version 1.10.1
To verify you have the right version on your path.
dart --version

Dart VM version: 1.10.1 (Mon May 11 14:08:44 2015) on "windows_x64"

Thursday, 4 June 2015

Programming Minecraft with Dart - mcpi-dart v0.1

The Minecraft phenomena has been an amazing success with game players and coders. A version was released for the Raspberry Pi computer that allowed programming via a Python wrapper. The same programming API was added to regular Minecraft servers via Raspberry Juice.

Of course, it would be better if you could program Minecraft in Dart... and now you can! I have put up a first version of mcpi-dart on GitHub. An early version so please be kind, try it out and provide feedback. Make sure you Dart is up to date as it requires async.

This entire project was inspired by the awesome book 'Adventures in Minecraft' by Martyn O'Hanlon.

Let's take a run through the main.dart demo sample.

Connecting to the server

Make sure the IP is pointing to your Minecraft server running Bukkit & Raspberry Juice. This was tested on a slightly older Minecraft 1.6.4 on Bukkit Server with Raspberry Juice.

  mci = new Minecraft();
  await mci.connect("192.168.0.110", 4711);

Chat Messages

Talkie talkie! Easy one this.

mci.chat("Dart is awesome!");

Placing Blocks

This is what it is all about. Let's get building!

blockDemo() {
  print("Block Demo Start");
  for (int i = 0; i < 99; i++) {
    mci
      ..setBlock(1, i, 0, Block.GOLD_BLOCK)
      ..setBlock(3, i, 0, Block.DIAMOND_BLOCK)
      ..setBlock(5, i, 0, Block.WOOL);
  }
  print("Block Demo End");
}

Getting the Player's Position

This method is a little trickier as we have to await a response.

  var s = (await mci.getPos());
  print(s);

Building a Rainbow

Just for fun :-)

  print("Starting rainbow...");
  var colors = [
    Block.BRICK_BLOCK,
    Block.GOLD_BLOCK,
    Block.MELON,
    Block.DIAMOND_BLOCK,
    Block.SANDSTONE,
    Block.GLOWSTONE_BLOCK,
    Block.LAPIS_LAZULI_BLOCK
  ];

  var height = 80;

  for (int x = 0; x < 128; x++) {
    for (int ci = 0; ci < colors.length; ci++) {
      double y = math.sin((x / 128.0) * math.PI) * height + ci;
      mci.setBlock(x - 64, y.round(), 0, colors[(colors.length - 1) - ci]);
    }
  }
  print("Built rainbow.");

Next steps

  • Some blocks require data rather than just an ID.
  • Get package onto Pub.
  • More Demos!

  • Monday, 1 June 2015

    Diving Into Dart HTML5 Demo Collection

    I have been wanting to gather all the HTML5 demos form this blog into one page for a while now. Thankfully the awesome Google+ has come up with its Collections which helps me share it with you.

    Enjoy!