Skip to content

Instantly share code, notes, and snippets.

View xr1337's full-sized avatar

Sufiyan Yasa xr1337

View GitHub Profile

Best in Class iOS Apps

What things can I quantify that help make an app great?

A summary of: A Best in Class iOS App

The five sections this document covers are:

  1. Accessibility: Designing for everyone is the right thing to do, and the best apps do it and they do it exceptionally well.
  2. Platform Technology: Apple loves it when apps utilize their new APIs to great effect, you should too. It’s not about shoehorning features, it’s about looking at your product and seeing how to utilize iOS around it.
@xr1337
xr1337 / DecodableResult.swift
Last active December 9, 2022 23:05
A json wrapper that holds the decode status of json objects. Generally used to decode JSON container items that may fail such as JSON Arrays.
/// This is wrapper that holds the decode status of json objects
/// It is useful for JSON arrays where if one child JSON node fails to decode, the whole array is not nil
/// Example use: try JSONDecoder().decode([DecodableResult<MyProduct>]).compactMap { try? $0.result.get() }
struct DecodableResult<T: Decodable>: Decodable {
let result: Result<T, Error>
init(from decoder: Decoder) throws {
result = Result(catching: { try T(from: decoder) })
}
}
@xr1337
xr1337 / Example script to open all logs
Last active May 24, 2021 08:02
A script to stream all the logs that simulator is currently booted
#/bin/bash
A=`xcrun simctl list | grep Booted | perl -ne 'print "$1\n" if / \(([0-9A-Z\-]+)\) /' | sort | uniq `
for UUID in $A
do
xcrun simctl spawn $UUID log stream --level debug\
--timeout 1h\
--style compact \
--predicate 'subsystem == "my.domain.name"' &
done
@xr1337
xr1337 / question.swift
Created August 10, 2020 01:59
unique substrings
import Cocoa
func fewestCoins(coins: String) -> Int {
let coinsArray = Array(coins)
let checkSet :Set = Set(coinsArray)
let countedSet :NSCountedSet = NSCountedSet()
// validation when the lenght of the string == amount uniq characters
if(checkSet.count == coins.count || checkSet.count == 0) {
return coins.count
@xr1337
xr1337 / main.go
Created August 10, 2020 01:58
medical_records
package main
import (
"encoding/json"
"fmt"
"net/http"
"sort"
"time"
)
@xr1337
xr1337 / Code.gs
Last active July 2, 2020 09:47
Google script to clean up root drive folder. All files are moved to their extension( mimetype) folder
/// returns extension from the file object
/// Queries the mimetype
const getExtension = function(file) {
var mime = file.getMimeType()
var docType = mime.split("/").pop()
return docType.split(".").pop()
};
/// send an email to myself when any files are moved
@xr1337
xr1337 / ViewController.swift
Created March 19, 2020 09:17
A viewcontroller to get last event time on the system
//
// ViewController.swift
//
// Created by Sufiyan Yasa on 19/03/2020.
// Copyright © 2020 Sufiyan Yasa. All rights reserved.
//
import Cocoa
import CoreGraphics
@xr1337
xr1337 / my_api_test.go
Created February 18, 2020 21:59
Syasa's 404 test
package main
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
"github.com/pkg/errors"
)
@xr1337
xr1337 / gist:5704489
Created June 4, 2013 08:32
PointInside
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
if (CGPathContainsPoint(touchPath, NULL, point, NO)) {
return YES;
}
return NO;
}
@xr1337
xr1337 / gist:5704301
Last active December 18, 2015 01:29
Adding a touch Path
@implementation RoundTouchButton{
CGPathRef touchPath;
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
touchPath = CGPathCreateWithEllipseInRect(CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), NULL);