Skip to content

Instantly share code, notes, and snippets.

View SNNafi's full-sized avatar
🎯
Focusing

Shahriar Nasim Nafi SNNafi

🎯
Focusing
View GitHub Profile
@SNNafi
SNNafi / Simulate varargs in Dart and create a logs function with varargs.md
Last active February 18, 2024 06:29
Simulate varargs in Dart and create a logs function with varargs
import 'dart:developer' as dev;
import 'package:flutter/foundation.dart';

typedef OnCall = dynamic Function(
    List<dynamic> args, Map<Symbol, dynamic> kwargs);

class VariadicFunction {
  VariadicFunction(this._onCall);
@SNNafi
SNNafi / PhoneHelper.swift
Created May 21, 2023 12:25 — forked from xmhafiz/PhoneHelper.swift
To get country prefix phone code using Swift 5
import Foundation
import CoreTelephony
struct PhoneHelper {
static func getCountryCode() -> String {
guard let carrier = CTTelephonyNetworkInfo().subscriberCellularProvider, let countryCode = carrier.isoCountryCode else { return "+" }
let prefixCodes = ["AF": "93", "AE": "971", "AL": "355", "AN": "599", "AS":"1", "AD": "376", "AO": "244", "AI": "1", "AG":"1", "AR": "54","AM": "374", "AW": "297", "AU":"61", "AT": "43","AZ": "994", "BS": "1", "BH":"973", "BF": "226","BI": "257", "BD": "880", "BB": "1", "BY": "375", "BE":"32","BZ": "501", "BJ": "229", "BM": "1", "BT":"975", "BA": "387", "BW": "267", "BR": "55", "BG": "359", "BO": "591", "BL": "590", "BN": "673", "CC": "61", "CD":"243","CI": "225", "KH":"855", "CM": "237", "CA": "1", "CV": "238", "KY":"345", "CF":"236", "CH": "41", "CL": "56", "CN":"86","CX": "61", "CO": "57", "KM": "269", "CG":"242", "CK": "682", "CR": "506", "CU":"53", "CY":"537","CZ": "420", "DE": "49", "DK": "45", "DJ":"253", "DM": "1", "DO": "1", "DZ": "213", "EC": "593"
//------------------------------------------------------------------------
// The SwiftUI Lab: Advanced SwiftUI Animations
// https://swiftui-lab.com/swiftui-animations-part1 (Animating Paths)
// https://swiftui-lab.com/swiftui-animations-part2 (GeometryEffect)
// https://swiftui-lab.com/swiftui-animations-part3 (AnimatableModifier)
//------------------------------------------------------------------------
import SwiftUI
struct ContentView: View {
@SNNafi
SNNafi / ArabicText Regex.md
Last active November 7, 2021 17:57
Detect Arabic Characters Using Regex

Detect all Arabic Characters:

Work in android [1]

\p{InArabic}+

Work in flutter with this package [2]

[\u0600-\u06FF]

@SNNafi
SNNafi / English Date to Bangla Date (Swift)
Last active March 30, 2023 08:24
Convert English Date to Bangla Date i.e. 22/03/2021 -> ৮ চৈত্র, ১৪২৭ in Swift. This is only for Bangladesh.
/// Convert English date to Bangla date. This is only for Bangladesh. WestBengla have different method
struct BanglaDate {
private let date: Date
private let calendar = Calendar(identifier: .gregorian)
private let dateComponents: DateComponents
private let timeZone = TimeZone(identifier: "Asia/Dhaka")!
private let banglaMonths = ["বৈশাখ","জ্যৈষ্ঠ", "আষাঢ়","শ্রাবণ","ভাদ্র", "আশ্বিন","কার্তিক","অগ্রহায়ণ","পৌষ","মাঘ", "ফাল্গুন","চৈত্র"]
private let banglaSeasons = ["গ্রীষ্ম", "বর্ষা", "শরৎ", "হেমন্ত", "শীত", "বসন্ত"]
private let banglaWeek = ["রবিবার", "সোমবার", "মঙ্গলবার", "বুধবার", "বৃহস্পতিবার", "শুক্রবার", "শনিবার"]
private var totalDaysInMonth = [31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30];