Skip to content

Instantly share code, notes, and snippets.

View MMnasrabadi's full-sized avatar
🤠
i am happy

Mohammad Mohammadi Nasrabadi MMnasrabadi

🤠
i am happy
View GitHub Profile
// clean remore memory leak
protocol Weakifiable: class { }
extension NSObject: Weakifiable {}
extension Weakifiable {
func weakify<T, Z>(_ code: @escaping (Self, T) -> Z) -> (T) -> Z? {
return { [weak self] data in
guard let self = self else { return nil}
@MMnasrabadi
MMnasrabadi / gist:4b256d2ab2af7257210911a99cd77a9c
Last active June 13, 2024 16:02
GitKraken open Private Repository
Installing older version of Gitkraken is the only solution I guess to work on private repo if you want it for free and without student developer pack.
From the release notes, the last version to support private repo is v6.5.1.
@MMnasrabadi
MMnasrabadi / gist:c35337677c2d368dab967eeab685ff75
Created September 12, 2020 17:31 — forked from ebraminio/gist:5292017
Check Iranian National Code Validity - بررسی صحت کد ملی ایرانی - Clojure, C#, Ruby, JavaScript, Python, Scala, Java 8, PHP, C, Go, Swift, Kotlin, Groovy, Rust, Haskell, Erlang, Elixir
// Check Iranian National Code Validity - Clojure, C#, Ruby, JavaScript, Python, Scala, Java 8, PHP, C, Go, Swift, Kotlin, Groovy, Rust, Haskell, Erlang, Elixir
// بررسی صحت کد ملی ایران - کلوژر، سی‌شارپ، روبی، جاوااسکریپت، پایتون، اسکالا، جاوا ۸، پی‌اچ‌پی، سی، گو، سوئیفت، کاتلین، گرووی، راست، هسکل، ارلنگ، الکسیر
// در نسخه‌های قبل یکسان بودن اعداد نا معتبر تشخیص داده می‌شد ولی
// اعداد یکسان نامعتبر نیست http://www.fardanews.com/fa/news/127747
// بعضی از پیاده‌سازی‌ها سریع نیستند، می‌توانید نسخهٔ خود را بر پایهٔ
// نسخهٔ سی یا گو ایجاد کنید که بهترین سرعت را داشته باشد
/**
@aheze
aheze / DocumentPicker.swift
Last active April 11, 2022 11:09
UIDocumentPickerViewController example in Swift 5. Bug fixed version of this article: https://medium.com/flawless-app-stories/a-swifty-way-to-pick-documents-59cad1988a8a
//
// DocumentPicker.swift
import UIKit
import MobileCoreServices
protocol DocumentDelegate: class {
func didPickDocument(document: Document?)
}
@IanKeen
IanKeen / EntryPoint.swift
Last active March 13, 2025 00:22
Example main.swift
import Foundation
import SwiftUI
let isUITesting = /* your UI test detection here */
@main
struct EntryPoint {
static func main() {
if isUITesting {
UITestApp.main()
@AliSoftware
AliSoftware / Demo.swift
Last active October 31, 2023 12:25
NestableCodingKey: Nice way to define nested coding keys for properties
struct Contact: Decodable, CustomStringConvertible {
var id: String
@NestedKey
var firstname: String
@NestedKey
var lastname: String
@NestedKey
var address: String
enum CodingKeys: String, NestableCodingKey {
@MMnasrabadi
MMnasrabadi / fazl-cheshmak-zan.sh
Last active June 25, 2020 11:34 — forked from iamvee/fazl-cheshmak-zan.sh
This is from the grace of my Lord
echo "\033[31;32m \033[0m"
echo "\033[31;32m ## \033[0m"
echo "\033[31;32m ### \033[0m"
echo "\033[31;32m ###** #########*####**** \033[0m"
echo "\033[31;32m ## ############********* #* \033[0m"
echo "\033[31;32m *######***** ### #* \033[0m"
echo "\033[31;32m # * #* \033[0m"
echo "\033[31;32m ## # # ## ###' #*
echo -e "\033[31;6m \033[0m"
echo -e "\033[31;6m \033[0m"
echo -e "\033[31;6m \033[0m"
echo -e "\033[31;6m ## \033[0m"
echo -e "\033[31;6m ### \033[0m"
echo -e "\033[31;6m ###** #########*####**** \033[0m"
echo -e "\033[31;6m ## ############********* #* \033[0m"
echo -e "\033[31;6m *######*****
@bardonadam
bardonadam / Form.swift
Created December 12, 2019 08:11
Custom decode with SomeKindOfBool
struct Form: Codable, Equatable {
let id: Int
let type: FType
let name: String
let code: String
let hasScreenshot: Bool
let total: Int
let totalUnique: Int
let opened: Int
@SomeKindOfBool var active: Bool