Skip to content

Instantly share code, notes, and snippets.

View ali2236's full-sized avatar
💭
Stuff'n Things!

Ali Qanbari ali2236

💭
Stuff'n Things!
View GitHub Profile
Future<Size> resolveSize(ImageProvider image) async {
final resultController = StreamController<Size>();
resolve(image, (info, _) {
final size = Size(
info.image.width.toDouble(),
info.image.height.toDouble(),
);
resultController.sink.add(size);
});
Future<Size> resolveSize(ImageProvider image) async {
final completer = Completer<Size>();
resolve(image, (info, _) {
final size = Size(
info.image.width.toDouble(),
info.image.height.toDouble(),
);
completer.complete(size);
});
@ali2236
ali2236 / wumpus.dart
Last active July 6, 2021 16:45
AI Homework #4
/*
Ali Ghanbari - 970216657
AI Homework 4 - Wumpus World
*/
import 'package:flutter/material.dart';
///#######################################
/// constants
/// ######################################
@ali2236
ali2236 / cannibals-missionaries.dart
Last active June 28, 2021 16:12
AI homework #3
/*
Ali Ghanbari - 970216657
online compiler: https://dartpad.dev/a2c7d1d325c61bf06df68c85235d8ae9?null_safety=true
*/
const n = 3;
enum Position { Left, Right }
enum Move { MM, M, MC, C, CC, None }
void main() {
/*
* Ali Ghanbari - 970216657
* online compiler: https://dartpad.dev/b7812076139d58b2c46258c33b5e7f30?null_safety=true
*/
import 'dart:math';
const n = 8;
enum Moves { Up, Down }
final random = Random();
/*
* Ali Ghanbari - 970216657
* online compiler: https://dartpad.dev/a69b65959d0207f02adf4e78c532f87a?null_safety=true
*/
///
/// Constants
///
enum Action { Left, Right, Suck, Idle }
enum RoomState { Clean, Dirty }
/*
* Ali Ghanbari - 970216657
* online compiler: https://dartpad.dev/a72a868f4690256e2f58f69b01823942?null_safety=true
*/
///
/// Constants
///
enum Action { Left, Right, Suck }
enum RoomState { Clean, Dirty }
@ali2236
ali2236 / Q28948.py
Created January 11, 2021 15:31
Quera problem solution
s = list(input())
stk = []
for c in s:
if c == '=':
if stk:
stk.pop()
else:
stk.append(c)
print(''.join(stk))
@ali2236
ali2236 / exception_chaning.dart
Last active December 3, 2020 20:07
how to chain exceptions in dart.
import 'dart:async';
void main() {
runZoned(() {
try {
try {
throw 'exception 1';
} catch (e) {
throw LinkedException('exception 2',e);
}
@ali2236
ali2236 / html-attr-filter.dart
Created November 8, 2020 19:34
Filters a list of html elements based on their attributes
import 'package:html/parser.dart';
void main() {
var document = parse(body);
var selectElements = document
.getElementsByClassName('hello')
.where((element) => element.attributes['data-time'] == '9112020')
.map((item) => item.text)
.toList();