Skip to content

Instantly share code, notes, and snippets.

View sethladd's full-sized avatar

Seth Ladd sethladd

View GitHub Profile
sayHi() {
print('hi');
}
@sethladd
sethladd / animated_text_flutter.dart
Created December 19, 2015 19:03
My first animated text with Flutter. This is using a very early version of Flutter. This probably won't work by the time you stumble across this code. :)
import 'package:flutter/material.dart'
show
BuildContext,
Positioned,
Stack,
State,
StatefulComponent,
Text,
Widget,
runApp;
@sethladd
sethladd / designer.html
Last active August 29, 2015 14:10
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<polymer-element name="my-element">
<template>
<style>
#core_header_panel {
@sethladd
sethladd / simple_serialization_tests.dart
Created August 5, 2014 21:07
Looking at both a simple by-hand JSON serialization, and an "automatic" serialization via mirrors. Note: this is by design extremely limited and only for illustration in a mailing list thread. Your need are almost certainly different and will need something custom.
import 'dart:convert';
import 'package:smoke/smoke.dart' as smoke;
@MirrorsUsed(targets: const [SimpleWithMirrors, Simple], override: '*')
import 'dart:mirrors';
class Simple {
int id;
String name;
@sethladd
sethladd / pubspec.yaml
Created March 24, 2014 17:12
dart:js and package:js test for code size
name: testjsinterop
description: A sample web application
dependencies:
browser: any
js: any
quiver: any
@sethladd
sethladd / sortings.dart
Created March 10, 2014 04:04
Experiments with sorting algorithms in Dart, from Wikipedia articles.
import 'dart:math';
// http://en.wikipedia.org/wiki/Bubble_sort
void bubble(List list) {
var n = list.length;
while (n != 0) {
var newn = 0;
for (var i = 1; i < n; i++) {
if (list[i-1] > list[i]) {
@sethladd
sethladd / app.dart
Created February 12, 2014 00:35
Example of lazy loading with Dart.
import 'dart:async';
@lazy
import 'big_lib.dart' as big show soManyFunctions;
const lazy = const DeferredLibrary('big', uri: 'big.js');
void main() {
lazy.load().then((_) {
big.soManyFunctions();
import 'dart:collection';
void main() {
var list = new WatchList([1,2,3,4,5]);
var mapped = list.where((x) => x.isEven).map((x) => x*2);
// What is printed here?
print(list.accessCount);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Addtotable</title>
<link rel="stylesheet" href="addtotable.css">
<link rel="import" href="my_table.html">
<script type="application/dart">export 'package:polymer/init.dart';</script>
@sethladd
sethladd / secret_santas.dart
Created December 9, 2013 05:46
My humble entry for Dart Dare - Secret Santa. I'm sure there are smaller or faster ways to do this. However, I wanted to try to solve the problem with sorting and processing lists. The entire solution hinges on sorting the santas by last name and by family size. Features of Dart that I used: * Classes * String interpolation * Type annotations * …
class Person {
String firstName, lastName;
Person(List<String> raw) : firstName = raw[0], lastName = raw[1];
String toString() => '$firstName $lastName';
}
/**
* Expects one person per line, each line containing a first and last name
* separated by a single space.
*/