This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you have an array or string containing cell data for a "grid", | |
// you can calculate x and y coords using division and the row length. | |
// define the row length in the virtual grid | |
const rowLength = 8; | |
// create a 1D model representing the "grid" | |
final onScreenKeyboard = 'abcde123fghij456klmno789pqrst.@0uvwxyz_/^ '; | |
// this function will return the grid position of the given content (content must be unique) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String meeting(String s) { | |
final people = s.split(';').map((String name) => Person.fromData(name)).toList(); | |
people.sort(); | |
return people.join(); | |
} | |
class Person implements Comparable<Person> { | |
final firstName; | |
final lastName; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() async { | |
final cache = await Cache.createCache(); | |
} | |
class Cache { | |
static Db myDb; | |
static createCache() async { | |
if (myDb == null) { | |
myDb = await Future.delayed(Duration(seconds: 1));; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Utils { | |
static search(name: String, obj: any, results: Array<any>) { | |
for (var key in obj) { | |
if (obj.hasOwnProperty(key)) { | |
const value = obj[key]; | |
if (key == name) { | |
results.push(value); | |
} | |
else if (typeof value === 'object') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const List<String> wordList = const ["PLENTY","ACHIEVE","CLASS","STARE","AFFECT","THICK","CARRIER","BILL","SAY","ARGUE","OFTEN","GROW","VOTING","SHUT","PUSH","FANTASY","PLAN","LAST","ATTACK","COIN","ONE","STEM","SCAN","ENHANCE","PILL","OPPOSED","FLAG","RACE","SPEED","BIAS","HERSELF","DOUGH","RELEASE","SUBJECT","BRICK","SURVIVE","LEADING","STAKE","NERVE","INTENSE","SUSPECT","WHEN","LIE","PLUNGE","HOLD","TONGUE","ROLLING","STAY","RESPECT","SAFELY"]; | |
const List<String> imageList = const [ | |
"https://i.imgur.com/kReMv94.png", | |
"https://i.imgur.com/UFP8RM4.png", | |
"https://i.imgur.com/9McnEXg.png", | |
"https://i.imgur.com/vNAW0pa.png", | |
"https://i.imgur.com/8UFWc9q.png", | |
"https://i.imgur.com/rHCgIvU.png", | |
"https://i.imgur.com/CtvIEMS.png", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// O(1) | |
// constant | |
bool isFirstElementNull(List<String> elements) { | |
return elements.first == null; | |
} | |
// O(n) | |
// growth is linear in direct proportion to the size of the data set | |
bool containsValue(List<String> elements, String value) { | |
for (String element in elements) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:html' show Element, NodeTreeSanitizer; | |
import 'package:angular2/core.dart' | |
show Directive, Input, OnChanges, SimpleChange; | |
@Directive(selector: '[safeInnerHtml]') | |
class SafeInnerHtml implements OnChanges { | |
Element _el; | |
SafeInnerHtml(this._el); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConfigService { | |
var _config; | |
Completer _waitForConfig = new Completer(); | |
ConfigService() { | |
doHttpCall().then((result) { | |
_config = result; | |
_waitForConfig.complete(_config); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void downloadFileToClient(String filename, String text) { | |
AnchorElement tempLink = document.createElement('a'); | |
tempLink | |
..attributes['href'] = 'data:text/plain;charset=utf-8,${Uri.encodeComponent(text)}' | |
..attributes['download'] = filename | |
..click(); | |
} |
NewerOlder