Skip to content

Instantly share code, notes, and snippets.

View HassanTeslim007's full-sized avatar
💭
Let's talk Flutter and Dart

Alpha HassanTeslim007

💭
Let's talk Flutter and Dart
View GitHub Profile
@HassanTeslim007
HassanTeslim007 / search_repository.dart
Last active March 31, 2024 14:58
The repository I'll like to write the tests for.
import 'dart:convert';
import 'dart:developer';
import 'package:lt_challenge/core/failure/exceptions.dart';
import 'package:lt_challenge/core/utils/secrets.dart';
import 'package:lt_challenge/features/search/data/models/searchmodel.dart';
import 'package:lt_challenge/features/search/domain/entities/search.dart';
import 'package:http/http.dart' as http;
abstract interface class SearchDataSource {
@HassanTeslim007
HassanTeslim007 / ExpansionTile.dart
Created August 6, 2023 18:50
Using Expansion TIle Widget
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@HassanTeslim007
HassanTeslim007 / main.dart
Last active July 28, 2023 20:12
Using Slivers
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@HassanTeslim007
HassanTeslim007 / main.dart
Created November 18, 2022 22:09
Learning DSA
void main() {
// bool xx = balanceTheParenthesis('h((e))llo(world)()) ');
Node<int> x = Node(value: 1, next: Node(value: 2, next: Node(value: 4)));
print(x);
final list = LinkedList<int>();
list.push(3);
list.push(2);
list.push(1);
@HassanTeslim007
HassanTeslim007 / main.dart
Last active October 27, 2022 19:15
HNG9 Task1
void main() {
Circle circle1 = Circle();
print('''Circle 1:
Area: ${circle1.getArea()}
Circumference: ${circle1.getCircumference()}
Description: ${circle1.getDescription()}
Color: ${circle1.getColor()}
''');
@HassanTeslim007
HassanTeslim007 / AutogenerateInt.dart
Created June 18, 2022 11:06
Auto generate numbers after a specified time and add to existing sum of previously generated numbers
import 'dart:math';
import 'dart:async';
void main() {
var random = Random();
int randomNumber = 0;
int sum = 0;
//I'm using 2 seconds here and I'm terminating when it sums up to over 200
//Numbers are generated between 0-100
@HassanTeslim007
HassanTeslim007 / max_profit.dart
Last active April 19, 2022 09:25
LeetCode 121: Best time to buy and sell stock
import 'dart:math' as math;
void main() {
var prices = [4,2,5,6,7,8];
print( maxProfit(prices));
}
int maxProfit(List<int> prices){
int maxProfit = 0;
int profit = 0;
int low = 0; int high = 1;
@HassanTeslim007
HassanTeslim007 / Roman_Numeral_Converter.py
Last active April 5, 2022 07:51
Python equivalent of Roman Numeral Converter
import re
def RomanConverter(s)->int:
romanNumerals = {'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000,'IV':4,'IX':9,'XL':40,'XC':90,'CD':400,'CM':900}
i = 0;
num = 0
valid = bool(re.search(r"^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$",s))
if valid:
try:
while i < len(s):
if i+1 < len(s) and s[i:i+2] in romanNumerals:
@HassanTeslim007
HassanTeslim007 / Roman_Numeral_Converter.dart
Created April 5, 2022 07:33
Gist for converting Roman Numerals to Numbers
void main() {
String? numeral = 'XIV'.toUpperCase(); //You can choose to accept user input here
convertRomanNumeral(numeral);
}
int convertRomanNumeral(String numeral) {
Map<String, int> numeralValues = {
'I': 1,
///Code starts here
void main() {
///Call method with custom list and target
linearSearch([1, 2, 3, 4, 5, 6, 7, 8, 9], target: 3);
}
void linearSearch(List list, {target}) {
///Prints the index position of the target, else return null