Skip to content

Instantly share code, notes, and snippets.

View omarzer0's full-sized avatar
🏠
Working from home

Omar AZ omarzer0

🏠
Working from home
View GitHub Profile
@omarzer0
omarzer0 / MyServiceInterceptor.kt
Last active January 10, 2022 13:08
Service interceptor to update any okHttp/Retrofit header during run time when using hilt
@Singleton
class MyServiceInterceptor @Inject constructor(
private var sessionToken: String = ""
) : Interceptor {
fun setSessionToken(sessionToken: String) {
this.sessionToken = sessionToken
}
override fun intercept(chain: Interceptor.Chain): Response {
@omarzer0
omarzer0 / StringReduceChallenge.kt
Created January 23, 2022 22:01
Fun after an exam with kotlin extension functions to solve simple challenge for solving this challenge.
fun main() {
//abcabc => cba => aa = 2
val two = stringReduceChallenge("abcabc")
println(two)
// aaaa = 4
val four = stringReduceChallenge("aaaa")
println(four)
// abcab => cbb => ab => c = 1
@omarzer0
omarzer0 / MergeSortKT.kt
Last active August 17, 2022 16:23
Merge Sort Algorithm using kotlin
fun main() {
val arr = arrayOf(9, 3, 6, 7, 3, 2, 1, 5, 4, 7, 5)
mergeSort(arr)
println(arr.contentToString())
}
fun mergeSort(inputArray: Array<Int>) {
val inputLength = inputArray.size
if (inputLength < 2) return
@omarzer0
omarzer0 / MergeSort.java
Last active August 17, 2022 16:23
Merge Sort Algorithm using Java
import java.util.Arrays;
public class MergeSort {
public static void main(String[] args) {
int[] arr = new int[]{9, 3, 6, 7, 3, 2, 1, 5, 4, 7, 5};
mergeSort(arr);
System.out.println(Arrays.toString(arr));
}
@omarzer0
omarzer0 / Second Session - youtube.dart
Created October 10, 2022 20:20
Code for the second session for Flutter course in Roqay
import 'package:flutter/material.dart';
// The line below is to stop lint warning "Prefer const with constant constructors"
// ignore_for_file: prefer_const_constructors
void main() {
runApp(MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
@omarzer0
omarzer0 / whatsapp.dart
Created October 13, 2022 15:56
Third session for flutter in Roqay
// ignore_for_file: prefer_const_constructors
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
debugShowCheckedModeBanner: false,
home: DefaultTabController(
length: 4,
initialIndex: 1,
child: Scaffold(
@omarzer0
omarzer0 / encryptAndDecryptTask.dart
Created October 27, 2022 16:39
Encrypt And Decrypt Task of flutter sessions at Roqay
import 'dart:convert';
import 'dart:io';
void main() {
stdout.write("text: ");
String text = stdin.readLineSync(encoding: utf8) ?? "";
stdout.write("how many shifts: ");
int shiftNumber = int.tryParse(stdin.readLineSync(encoding: utf8) ?? "")!;
stdout.write("operation is (1 for encrypt, 0 to decrypt): ");
bool operation = int.tryParse(stdin.readLineSync(encoding: utf8) ?? "")! == 1;
@omarzer0
omarzer0 / passwordStrengthTask.dart
Created October 27, 2022 16:42
Measure passwords strength task of flutter sessions at Roqay
import 'dart:convert';
import 'dart:io';
void main() {
var pass = stdin.readLineSync(encoding: utf8) ?? "";
getPasswordStrength(pass);
}
void getPasswordStrength(String pass) {
import 'package:http/http.dart' as http;
void main(){
// Uri uri1 = Uri.parse('https://example.com/whatsit/create');
// http.get(uri1).then((value) => print(value.statusCode));
// Uri uri2 = Uri.parse('https://jsonplaceholder.typicode.com/albums/1');
// http.get(uri2).then((value) => print(value.statusCode));
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(home: Screen()));
}
class Screen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(