Skip to content

Instantly share code, notes, and snippets.

View mohshin-shah's full-sized avatar

Mohshin Shah mohshin-shah

View GitHub Profile
@mohshin-shah
mohshin-shah / testing.html
Created July 11, 2025 08:42
Fairprice Testing
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>iOS Deeplink Tester</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
.clamp-3-lines {
display: -webkit-box;
-webkit-line-clamp: 3;
@mohshin-shah
mohshin-shah / String+subscript.swift
Created November 18, 2022 04:18 — forked from foxicode/String+subscript.swift
Swift String subscript extension
import Foundation
extension String {
subscript (i: Int) -> Character {
return self[index(startIndex, offsetBy: i)]
}
subscript (bounds: CountableRange<Int>) -> Substring {
let start = index(startIndex, offsetBy: bounds.lowerBound)
let end = index(startIndex, offsetBy: bounds.upperBound)
@mohshin-shah
mohshin-shah / clean_code.md
Created August 26, 2020 06:48 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@mohshin-shah
mohshin-shah / DynamicHeightCalculable
Created October 2, 2018 02:24
Calculates the UICollectionViewCell height from XIB
public extension NSObject {
public class func lg_loadFromNib(nibName: String? = nil) -> Self {
let name = nibName ?? String(describing: self)
return self.lg_loadFromNib(nibName: name, objectType: self)
}
private class func lg_loadFromNib<T>(nibName: String, objectType: T.Type) -> T {
let nibObjects = UINib(nibName: nibName, bundle: nil).instantiate(withOwner: nil, options: nil)
class Solution {
func compareVersion(version1: String, _ version2: String) -> Int {
var v1 = version1.characters.split(".").map { Int(String($0)) }
var v2 = version2.characters.split(".").map { Int(String($0)) }
var result = 0
for i in 0..<max(v1.count,v2.count) {
let left = i >= v1.count ? 0 : v1[i]
let right = i >= v2.count ? 0 : v2[i]
if (left == right) {
//
// UILabel+JumpingDots.swift
// JumpingDots
//
// Copyright (c) 2016 Arkadiusz Holko. All rights reserved.
//
import UIKit
import ObjectiveC
//
// AlertController.swift
// MSAlertControllerDemo
//
// Created by Mohshin Shah on 19/10/2016.
// Copyright © 2016 Mohshin Shah. All rights reserved.
//
import Foundation
import UIKit
struct S0<V> {
typealias F = () -> V
}
struct S1<T1,V>{
typealias F = (T1) -> V
}
//0, 0
func curry<T1, V>(f: S1<T1, V>.F, a1:T1) -> S0<V>.F {
@mohshin-shah
mohshin-shah / dispatch.swift
Created October 18, 2016 07:52 — forked from amw/dispatch.swift
Swift wrapper for Grand Central Dispatch (GCD)
//
// dispatch.swift
//
// Created by Adam Wróbel. Read more at:
// http://adamwrobel.com/blog/2016/05/08/swift-gcd-wrapper/
//
import Foundation
internal extension dispatch_queue_t {
@mohshin-shah
mohshin-shah / README.md
Created October 17, 2016 08:45 — forked from cgrieger/README.md
Fixing git ssl client certs on OSX Mavericks

git clone - SSLRead() return error -9824

  1. Run fix.sh

  2. git is installed to /opt/git

  3. Add git to path

echo "export PATH=/opt/git/bin:$PATH" &gt;&gt; ~/.bash_profile