Skip to content

Instantly share code, notes, and snippets.

Jermaine Oppong graphicbeacon

Block or report user

Report or block graphicbeacon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
graphicbeacon / generics_example_1.dart
Created Dec 19, 2018
Sample code for "Ever been stumped by <E>..." Medium post
View generics_example_1.dart
class CacheItem<A> { // Using the letter A
CacheItem(A this.itemToCache);
final itemToCache;
String get detail => '''
Cached item: $itemToCache
The item type is $A
graphicbeacon / hacker_news_scraper_test.dart
Created Dec 17, 2018
Code snipper for "Write your first Web Scraper in Dart" Medium post
View hacker_news_scraper_test.dart
void main() {
MockClient client = null;
test('calling initiate(client) returns a list of storylinks', () async {
// Arrange
client = MockClient((req) => Future(() => Response('''
<td class="title">
<a class="storylink" href="">Get started with Dart</a>
graphicbeacon / hacker_news_scraper.dart
Created Dec 17, 2018
Code snippet for "Write your first Web Scraper in Dart" Medium post
View hacker_news_scraper.dart
// lib/hacker_news_scraper.dart
import 'dart:convert';
import 'package:http/http.dart';
import 'package:html/parser.dart';
import 'package:html/dom.dart';
Future initiate() async {
// Make API call to Hackernews homepage
var client = Client();
graphicbeacon / virtual_dom.dart
Created Dec 6, 2018
A lightweight Virtual DOM implementation in Dart
View virtual_dom.dart
import 'dart:html';
void main() {
var vApp = createElement('div',
attrs: {
'id': 'app',
children: [
'Hello Cat!',
graphicbeacon / async-with-futures.dart
Created Nov 22, 2018
Sample code demonstrating Asynchronous programming with Futures
View async-with-futures.dart
import 'dart:convert';
import 'dart:html';
import 'dart:async';
main() {
// Basic example
var result = Future(() => 'Hello World!');
result.then((data) => print(data));
graphicbeacon / interfaces-and-mixins.dart
Last active Nov 21, 2018
Sample code demonstration Interfaces and Mixins in Dart
View interfaces-and-mixins.dart
void main() {
var pixel = Phone('Pixel XL', 'Google');
class FeaturesMixin {
bool blueTooth = true;
bool dualSim = false;
bool NFC = true;
graphicbeacon / classes-and-inheritance.dart
Last active Nov 21, 2018
Sample code demonstrating Classes and Inheritance in Dart
View classes-and-inheritance.dart
void main() {
var johnny = Person('Johnny', 42)
..speak() = 'Big Johnny'
var johnnyB = Person('Johnny', 42);
print(johnny == johnnyB);
var bob = Employee('Bob', 23,;
graphicbeacon / serverside-post-request.dart
Last active Nov 21, 2018
Learn Dart #8: Perform a Server-side POST request in under 30 seconds (Solution)
View serverside-post-request.dart
import 'dart:io';
import 'dart:convert';
main() async {
var apiUrl = Uri.parse('');
var client = HttpClient(); // `new` keyword optional
// 1. Create request
HttpClientRequest request = await client.postUrl(apiUrl);
graphicbeacon / chat_room.dart
Last active Nov 8, 2018
Code snippet from "Build a chat application in Dart 2 (Part 2)" article
View chat_room.dart
// Absolute imports
import 'dart:html';
// Relative imports
import './view.dart';
class ChatRoomView implements View {
ChatRoomView(this.params) : _contents = DocumentFragment() {
graphicbeacon / read-and-write-files.dart
Last active Nov 21, 2018
Learn Dart #5: Read and write files in under 30 seconds
View read-and-write-files.dart
import 'dart:io';
main() async {
var file = File('data.txt');
var contents;
if (await file.exists()) {
// Read file
contents = await file.readAsString();
You can’t perform that action at this time.