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
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
@MMnasrabadi
MMnasrabadi / .gitignore xcode
Created July 24, 2019 07:22
Example .gitignore file for iOS projects
## .DS_Store
.DS_Store
## CocoaPods
Podfile.lock
Pods/
## Userdata
Pock.xcodeproj/xcuserdata/
Pock.xcworkspace/xcuserdata/
@MMnasrabadi
MMnasrabadi / Fix Internet connection in Android Emulator
Created July 24, 2019 07:24
Start the emulator from the command line
Cd ~/Library/Android/sdk/emulator
./emulator -list-avds
./emulator -avd Pixel_2_XL_API_26 -dns-server 8.8.8.8,8.8.4.4
@MMnasrabadi
MMnasrabadi / DNS Terminal on Mac
Last active August 15, 2019 09:25
Change the DNS Servers via Terminal on a Mac
# 1.For add : Once Terminal is open, enter the following command:
$ networksetup -setdnsservers Wi-Fi 178.22.122.100 185.51.200.2
# then press [Enter]
# 2.For Delete :
$ networksetup -setdnsservers Wi-Fi "Empty"
@MMnasrabadi
MMnasrabadi / ZSH and Oh My ZSH installations
Last active March 14, 2020 05:43
Setting up the beautiful terminal by ZSH and Oh My ZSH installations
Setting up the beautiful terminal by ZSH and Oh My ZSH installations
ohmyzsh github page:
https://github.com/ohmyzsh/ohmyzsh
Themes :
https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
@MMnasrabadi
MMnasrabadi / CodablePro.swift
Created March 23, 2020 15:18
extension on Codable
// Create by love : Mohammad Nasrabadi [github](https://github.com/mmnasrabadi)
import UIKit
protocol CodablePro: Codable {
func toJsonString() -> String
typealias JSON = [String : Any]
func toDictionary() -> JSON?
init?(json: JSON)
@MMnasrabadi
MMnasrabadi / Demo.swift
Created June 20, 2020 11:20 — forked from AliSoftware/Demo.swift
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 {
import Foundation
protocol TransformerType {
associatedtype BaseType
associatedtype TypeForCoding: Codable
static var encodeTransform: (BaseType) throws -> TypeForCoding { get }
static var decodeTransform: (TypeForCoding) throws -> BaseType { get }
}
@propertyWrapper
// Xcode 11b1
@propertyDelegate
struct Clamped<Value: Comparable> {
private var storage: Value
private var clamp: (Value) -> Value
init(min: Value, max: Value, initialValue: Value) {
let clampingFunction = { ($0...$0).clamped(to: min...max).lowerBound }
self.storage = clampingFunction(initialValue)
enum Demo {
case simple
case oneValue(Int)
case twoValues(String, Double)
case threeValues(one: Int, two: Float, [Int])
}
//: # Direct exposition in the enum
//: ## Sourcery Template