Skip to content

Instantly share code, notes, and snippets.

View Hesamedin's full-sized avatar
🏠
Busy Busy Busy

Hesam Hesamedin

🏠
Busy Busy Busy
View GitHub Profile
@Hesamedin
Hesamedin / pullCachedFilesFromDevice.sh
Created July 17, 2024 17:16
This is a helper script to pull cached files on the device (or Emulator). Android 13 and above doesn't let us see the cached files from the Device Explorer. So, this script help us to pull them and look at it whenever needed.
#!/bin/bash
####################################################################################################
# This is a helper script to pull cached files on the device (or Emulator).
# Android 13 and above doesn't let us see the cached files from the Device Explorer. So, this
# script help us to pull them and look at it whenever needed.
####################################################################################################
# Download the files of the app ($1: package name)
# and store it under the provided path ($2)
pullAllFilesUnderThePath() {
@Hesamedin
Hesamedin / Podfile
Created July 29, 2022 18:01
Podfile sample of a Flutter project.
# Uncomment this line to define a global platform for your project
platform :ios, '13.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
@Hesamedin
Hesamedin / clean_run_ios.sh
Last active July 29, 2022 19:49
Clean ios project of a Flutter project and Run it.
#!/bin/bash
set -e
echo "The script you are running is: $(dirname "$0")/$(basename "$0")"
function runDebug() {
flutter run iOS --debug --target=lib/main_dev.dart
}
function runRelease() {
@Hesamedin
Hesamedin / top_10_frequent_words.dart
Created May 4, 2022 17:43
Write a function top10words that takes as input a list of words and returns a list of 10 most frequent words in the input list
// import 'package:collection/collection.dart';
// Write a function top10words that takes as input a list of words
// and returns a list of 10 most frequent words in the input list
void main() {
// TODO:: call top10words on words list below
// var top10 = top10words(words);
// expects top10 to include "Iris", "Elisa", "Jack"
// Dart imports:
import 'dart:convert';
import 'dart:typed_data';
// Flutter imports:
import 'package:flutter/foundation.dart' show kIsWeb;
// Package imports:
import 'package:get_it/get_it.dart';
import 'package:universal_html/html.dart';
[
{
"origin": ["*"],
"method": ["GET"],
"maxAgeSeconds": 3600
}
]
import 'dart:convert';
import 'dart:html';
Future<void> downloadFile(String fileName, String pathToFile) async {
if (pathToFile.isEmpty) return;
if (!kIsWeb) return;
Uint8List? data = await FirebaseStorage.instance.ref(pathToFile).getData();
if (data == null) return;
String encodedData = base64Encode(data);
Future<void> storePushNotificationToken(String userId, String token) async {
final batch = _firestore.batch();
final pushTokenRef = _firestore.collection(FirestoreCollection.pushToken.path).doc(userId);
batch.set(
pushTokenRef,
{'userId': userId, 'token': token},
SetOptions(merge: true),
);
Scaffold(
appBar: AppBar(...),
body: WillPopScope(
onWillPop: onBackClick,
child: CustomScrollView(
slivers: <Widget>[
SliverToBoxAdapter(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
@Hesamedin
Hesamedin / build.gradle
Last active November 10, 2019 13:15
KTLint integration
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'
apply from: '../gradle/afsTasks.gradle' <========
android {
compileSdkVersion 28