Skip to content

Instantly share code, notes, and snippets.

View thosakwe's full-sized avatar
🎯
Focusing

Tobe Osakwe thosakwe

🎯
Focusing
View GitHub Profile
@thosakwe
thosakwe / flutter.dart
Created November 7, 2017 16:30
Examples of Dart syntax.
import 'package:flutter/material.dart';
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: const Text('My App'),
),
body: new Center(
@thosakwe
thosakwe / main.dart
Created November 7, 2017 17:16
Example of Dart HTML5 usage
import 'dart:html';
final ButtonElement $button = querySelector('#button');
final Iterable<AnchorElement> $links = querySelectorAll('a:not(.active)');
void main() {
$button.onClick.listen((_) {
window.alert('Hello, world!');
});
@thosakwe
thosakwe / foo_cmp.dart
Created November 7, 2017 17:50
Example Angular component
import 'package:angular/angular.dart';
@Component(selector: 'foo-cmp', templateUrl: 'foo_cmp.html')
class FooComponent {
String name = 'Bob';
List<String> colors = ['red', 'blue', 'green', 'fuchsia'];
}
@thosakwe
thosakwe / middleware.dart
Created December 28, 2017 02:56
Multi-tenancy Angel middleware
import 'dart:async';
import 'package:angel_framework/angel_framework.dart';
import 'package:mongo_dart/mongo_dart.dart';
/// Chooses the database associated with the [tenantId], and injects it into the [RequestContext].
///
/// @[Header] annotation is used to parse out the `x-tenant` header, if it is not present, a 400 is thrown.
Future<bool> chooseDatabase(@Header('x-tenant') tenantId, Db db, RequestContext req) async {
// Assuming that you have a collection that maps tenant ID's to collection names:
var mapping = await db.collection('tenants').findOne(where.id(new ObjectId.fromHexString(tenantId)));
@thosakwe
thosakwe / README.txt
Created February 6, 2018 19:06
Dynamic parser generator system???
## Concept
It sucks to do the following:
* Write an AST
* Write a scanner
* Write a parser
* Test the parser
* Write language documentation
So... Why not do it automatically?
@thosakwe
thosakwe / README.txt
Created March 3, 2018 20:34
Tampermonkey UserScript to auto-click Follow/Unfollow Buttons on Crowdfire
Press CTRL+SHIFT+Y (PC) or COMMAND+SHIFT+Y (Mac) to auto-click all the follow or unfollow buttons on Crowdfire,
with a small delay (200ms) in-between.
Sends a notification when the process completes. Saves a lot of time, and makes it much easier to grow your following
without all the clicking.
@thosakwe
thosakwe / README.md
Last active March 9, 2018 00:59
Basic Angel Deployment (Ubuntu 16.04 + nginx + systemd)

What?

An ASM-inspired language that uses some familiar constructs to make building ASM easier.

It's basically ASM, but labels are given a function syntax. There also exists the concept of pointers, which are converted into address literals.

Declaring external functions is also supported, which makes it possible to verify the syntax of calls at compile time.

All in all, the compiler will be written in C++, and should in theory be quite fast, because in reality it is just a simple transpiler.

import 'package:dig/delegate.dart';
import 'package:path/path.dart' as p;
main(_, SendPort sendPort) {
return Dig.run(sendPort, (Dig dig) async {
var dig = await Dig.create(sendPort);
// Wait for these tasks to finish, or run them if they have not been completed.
await dig.depend(['string_scanner', 'source_span:some_task']);
@thosakwe
thosakwe / foo.ts
Created May 5, 2018 02:47
*cries*
models {
// Define models (functions)
line(x: Num) -> Num
// Struct?
nlp(text: String, len: Num) -> (category: String, confidence: Num)
opts { cache }
}
train {