Skip to content

Instantly share code, notes, and snippets.

@kasperpeulen
kasperpeulen / README.md
Created July 24, 2015 04:44
How to generate random numbers in dart.
@kasperpeulen
kasperpeulen / README.md
Last active August 29, 2015 14:25
How to dynamically load HTML and insert into a webpage with Dart
@kasperpeulen
kasperpeulen / README.md
Last active August 29, 2015 14:25
args:CommandRunner example
@kasperpeulen
kasperpeulen / README.md
Last active August 29, 2015 14:25
A basic example of a command-based application.

#args:command_runner example

A basic example of a command-based application.

The command dart main.dart install [library] will add the library to the main.dart file. For example try dart main.dart install http:http.

Main library: args:command_runner
Main elements: CommandRunner CommandRunner.addCommand

@kasperpeulen
kasperpeulen / README.md
Last active August 29, 2015 14:25
Dartson is a dart library which converts Dart Objects into their JSON representation.

#dartson:dartson example

Dartson is a dart library which converts Dart Objects into their JSON representation.

It helps you keep your code clean of fromJSON and toJSON functions by using dart:mirrors reflection. It works after dart2js compiling.

Main library: dartson:dartson
Main elements: Dartson.JSON Dartson.encode
Gist: https://gist.github.com/kasperpeulen/ef38c9bda5dc586a78f1

@kasperpeulen
kasperpeulen / README.md
Last active August 29, 2015 14:25
Runs random simulations of the Monty Hall game and compares the two different strategies.

#dart:math dart:core example

Runs random simulations of the Monty Hall game and compares the two different strategies.

Suppose you're on a game show and you're given the choice of three doors. Behind one door is a car; behind the others, goats. The car and the goats were placed randomly behind the doors before the show. The rules of the game show are as follows: After you have chosen a door, the door remains closed for the time being. The game show host, Monty Hall, who knows what is behind the doors, now has to open one of the two remaining doors, and the door he opens must have a goat behind it. If both remaining doors have goats behind them, he chooses one randomly. After Monty Hall opens a door with a goat, he will ask you to decide whether you want to stay with your first choice or to switch to the last remaining door. Imagine that you chose Door 1 and the host opens Door 3, which has a goat. He then asks you "Do you want to switch to Door Number 2?" Is it to your advantage to change your choice? (Krau

@kasperpeulen
kasperpeulen / README.md
Last active August 29, 2015 14:26
How to use MDL on dynamic websites.

#mdl:mdl example

How to use MDL on dynamic websites.

Material Design Lite will automatically register and render all elements marked with MDL classes upon page load. However in the case where you are creating DOM elements dynamically you need to register new elements using the upgradeElement function.

Main library: mdl:mdl
Main element:
Gist: https://gist.github.com/kasperpeulen/d2f59227c054e82f825b

#mdl:mdl example

How to use MDL on dynamic websites.

Material Design Lite will automatically register and render all elements marked with MDL classes upon page load. However in the case where you are creating DOM elements dynamically you need to register new elements using the upgradeElement function.

Main library: mdl:mdl
Main element:
Gist: https://gist.github.com/kasperpeulen/d2f59227c054e82f825b

#mdl:mdl example

How to use MDL on dynamic websites.

Material Design Lite will automatically register and render all elements marked with MDL classes upon page load. However in the case where you are creating DOM elements dynamically you need to register new elements using the upgradeElement function.

Main library: mdl:mdl
Main element:
Gist: https://gist.github.com/kasperpeulen/d2f59227c054e82f825b

#mdl:mdl example

How to use MDL on dynamic websites.

Material Design Lite will automatically register and render all elements marked with MDL classes upon page load. However in the case where you are creating DOM elements dynamically you need to register new elements using the upgradeElement function.

Main library: mdl:mdl
Main element:
Gist: https://gist.github.com/kasperpeulen/d2f59227c054e82f825b