Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Jermaine Oppong graphicbeacon

🏠
Working from home
View GitHub Profile
@graphicbeacon
graphicbeacon / main.dart
Last active Aug 14, 2022
Solution for "Understanding Reflection in Dart" video tutorial on YouTube
View main.dart
import 'dart:io';
import 'dart:mirrors';
main() async {
var server = await HttpServer.bind('localhost', 8085);
await for (HttpRequest req in server) {
// Create InstanceMirror type from which
// we retrieve metadata information
var ref = reflect(Endpoint(req));
@graphicbeacon
graphicbeacon / server.dart
Created May 25, 2020
Shelf Dart Tutorial solution code
View server.dart
import 'dart:io';
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as io;
// For Google Cloud Run, set _hostname to '0.0.0.0'.
const _hostname = 'localhost';
const _port = 8080;
void main(List<String> args) async {
@graphicbeacon
graphicbeacon / chat-server.js
Last active Jun 8, 2022
A simple TCP chat server with NodeJS, based on the example provided by creationix.
View chat-server.js
var net = require('net');
var sockets = [];
var port = 8000;
var guestId = 0;
var server = net.createServer(function(socket) {
// Increment
guestId++;
socket.nickname = "Guest" + guestId;
@graphicbeacon
graphicbeacon / index.js
Last active Apr 21, 2022
How to create an application using the Monzo Bank API (Full solution)
View index.js
const express = require('express');
const request = require('request');
const app = express();
const oauthDetails = {
client_id: '[your client id]',
client_secret: '[your client secret]',
redirect_uri: 'http://localhost:3000/oauth/callback'
};
@graphicbeacon
graphicbeacon / main.dart
Last active Mar 11, 2022
"Dart File Upload Server Tutorial" solution for YouTube video tutorial
View main.dart
// bin/main.dart
import 'dart:io';
import 'package:mime/mime.dart';
main() async {
var server = await HttpServer.bind('localhost', 8085);
server.listen((request) async {
@graphicbeacon
graphicbeacon / console.dart
Last active Nov 2, 2021
Final snippets for "How to use JavaScript libraries in your Dart applications" article
View console.dart
// web/console.dart
@JS('console')
library console;
import 'package:js/js.dart';
external void log(dynamic str);
@graphicbeacon
graphicbeacon / main.dart
Created Nov 27, 2020
Shelf_router server example with CORS enabled
View main.dart
import 'package:shelf_router/shelf_router.dart';
import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart' as io;
void start() async {
// Initiate server
const port = 8081;
final app = Router();
// CORS Settings
@graphicbeacon
graphicbeacon / main.dart
Last active Sep 17, 2021
Solution code on "Flutter for React developers" YouTube tutorial
View main.dart
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:math' as math;
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@graphicbeacon
graphicbeacon / Dockerfile
Created May 17, 2020
Setup Dart with Docker
View Dockerfile
# ./Dockerfile
FROM google/dart-runtime
@graphicbeacon
graphicbeacon / main.dart
Created Feb 7, 2021
Convert map object to yaml in Dart
View main.dart
void main() {
final json = {
'name': 'package_name',
'version': '1.0.0',
'dependencies': {
'dep1': '^1.0.0',
'dep2': '^1.5.0',
'dep3': {
'git': 'https://github.com/graphicbeacon',
'home': {