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 / calc.dartl
Last active July 11, 2021 16:39
Dart lex/yacc?
%{
import 'calc.darty.dart';
%}
%%
[ \t\n] ;
[0-9]+ { yyval = int.parse(yytext); return T_NUMBER; }
\( { return T_LPAREN; }
\) { return T_RPAREN; }
\* { return T_TIMES; }
\/ { return T_SLASH; }
@thosakwe
thosakwe / README.md
Last active May 22, 2018 19:52
Dart build system?

DNB

This is a prototype of a CMake-based build tool for Dart native extensions. Combined with scripts, this would be comparable to node-gyp, but with actual Windows support, and no Python dependency.

DNB is designed to ensure portability across various platforms where Dart runs.

Examples explained

Note: In real projects, filenames would be dnb.yaml, dnb.macos.yaml, etc.

@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 {
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']);

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.

@thosakwe
thosakwe / README.md
Last active March 9, 2018 00:59
Basic Angel Deployment (Ubuntu 16.04 + nginx + systemd)
@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.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 / 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 / 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'];
}