Skip to content

Instantly share code, notes, and snippets.

View optimho's full-sized avatar
😀
I may be slow to respond.

Michael du Plessis optimho

😀
I may be slow to respond.
View GitHub Profile
@optimho
optimho / systemVariables.dart
Last active April 4, 2021 23:30
Dartmaking use of system variables
import 'dart:io';
import 'dart:convert';
void main(List<String> arguments) {
//run a command process
Process.run('ls', ['-l']).then((ProcessResult results) {
print(results.stdout);
print('Exit code: ${results.exitCode }'); //0 is good
});
@optimho
optimho / Dart_dateTime.dart
Last active April 5, 2021 03:58
Dart example use of callbacks and timer
import 'dart:async';
int counter=0;
void main(List<String> arguments) {
Duration duration =new Duration(seconds: 5);
Timer timer = new Timer.periodic(duration, timeOut);
print('Started: ${getTime()}');
}
@optimho
optimho / Await.dart
Created April 5, 2021 04:33
Dart, await example in asynchronus programming
import 'async.dart';
import 'dart:io';
main() async{
print('Statring:');
File file =await appendFile();
print('Appended to file ${file.path}');
print('END*******************');
import 'dart:io';
import 'dart:async';
main() async{
print ('Creat a file and write to it');
File file = await appendToFile();
print ('File has been appended');
print('now attempt to read the file');
@optimho
optimho / FileOperation.dart
Created April 5, 2021 05:27
Dart Find things in a big file
import 'dart:io';
import 'dart:async';
import 'dart:convert';
import 'package:pedantic/pedantic.dart';
void main(List<String> arguments) {
Directory pwd = Directory.current;
final myfile = new File(pwd.path + '/new.txt');
Directory temp = Directory.current;
@optimho
optimho / Assignment6.dart
Last active April 5, 2021 05:54
Dart File Search Operation
import 'dart:io';
import 'dart:async';
import 'dart:convert';
import 'package:pedantic/pedantic.dart';
void main(List<String> arguments) {
Directory pwd = Directory.current;
final myfile = new File(pwd.path + '/new.txt');
Directory temp = Directory.current;
@optimho
optimho / compress.dart
Created April 5, 2021 20:22
compression example
/*
This is more sample code showing compression and use of the assert command
In this example there is two examples of compression
A very large compression of the bible, reading it from a file, converting it to a list
removing whitespace and special characters with regex and then utf8 encoding
compressing the file with with gzip, uncompressing the file with gzip and comparing the file
to the original with the assert command. Unfortunately the assert fails, I am not
sure why, it looks good?
So I created another example on a smaller scale.
@optimho
optimho / zlib.dart
Last active April 6, 2021 01:53
Dart compression using Zlib
/*
This compares two compression codecs in DART and compares them
GZIP and ZLIB
*/
import 'dart:html_common';
import 'dart:io';
import 'dart:convert';
@optimho
optimho / codecss.dart
Created April 6, 2021 02:22
Compare Dart Codecs
/*
This compares two compression codecs in DART and compares them
GZIP and ZLIB
*/
import 'dart:io';
import 'dart:convert';
main (List<String> arguments){
@optimho
optimho / encryption.dart
Created April 11, 2021 07:32
Dart Encryption example
import 'dart:io';
import 'dart:math';
import 'package:pointycastle/pointycastle.dart';
import 'dart:typed_data';
import 'dart:convert';
import 'package:collection/collection.dart';
void main(List<String> arguments) {