Skip to content

Instantly share code, notes, and snippets.

View mrugeshtank's full-sized avatar
🎯
Focusing

Mrugesh Tank mrugeshtank

🎯
Focusing
View GitHub Profile
@Pitsko
Pitsko / icon_overlay.sh
Last active January 17, 2018 12:04
ios icon overlay script
version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${INFOPLIST_FILE}"`
build=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}"`
export PATH=$PATH:/usr/local/bin
function addOverlayInfo() {
income_icon_name=$1
outcome_icon_name=$2
echo "addOverlayInfo with income ${income_icon_name} and outcoming ${outcome_icon_name}"
@phynet
phynet / map-reduce-filter-flatMap.swift
Created March 19, 2017 16:54
Examples for flatMap, Map, Reduce, Filter in Swift
//reduce
//Use reduce to combine all items in a collection to create a single new value.
let numbers = [1, 3, 5, 7, 9]
//sum all values from the array (+)
let result = numbers.reduce(0, +)
//sum all values from the array (+) plus one
let result2 = numbers.reduce(1, +)
let result3 = numbers.reduce(1, *)
@speaktoalvin
speaktoalvin / IAPHelper.txt
Last active April 29, 2021 04:07
In App Purchase in Swift, with Receipt Validation
import UIKit
import StoreKit
//MARK: SKProductsRequestDelegate
extension IAPHelpers : SKProductsRequestDelegate
{
func productsRequest(request: SKProductsRequest, didReceiveResponse response: SKProductsResponse)
{
extension UserDefaults {
subscript<T>(key: String) -> T? {
get {
return value(forKey: key) as? T
}
set {
set(newValue, forKey: key)
}
}
//
// InAppManager.swift
//
// Created by Ellina Kuznetcova on 12/10/2016.
// Copyright © 2016 Flatstack. All rights reserved.
//
import Foundation
import StoreKit
@Starefossen
Starefossen / remoteDataTableView.swift
Last active January 16, 2023 09:50
Remote JSON Data to tableView in iOS 8.0 (Swift)
import UIKit
import Foundation
import XCPlayground
XCPSetExecutionShouldContinueIndefinitely()
class RemoteAPI {
func getData(completionHandler: ((NSArray!, NSError!) -> Void)!) -> Void {
let url: NSURL = NSURL(string: "http://itunes.apple.com/search?term=Turistforeningen&media=software")
let ses = NSURLSession.sharedSession()
@uhooi
uhooi / Makefile
Last active July 17, 2023 02:18
Makefile for iOS App development
PRODUCT_NAME := Foo
SCHEME_NAME := ${PRODUCT_NAME}
WORKSPACE_NAME := ${PRODUCT_NAME}.xcworkspace
UI_TESTS_TARGET_NAME := ${PRODUCT_NAME}UITests
TEST_SDK := iphonesimulator
TEST_CONFIGURATION := Debug
TEST_PLATFORM := iOS Simulator
TEST_DEVICE ?= iPhone 11 Pro Max
TEST_OS ?= 13.3
@netgfx
netgfx / addObservers.swift
Last active December 14, 2023 13:02
Add observers to AVPlayer
// listening for current item change
self.audioQueueObserver = self.playerQueue?.observe(\.currentItem, options: [.new]) {
[weak self] (player, _) in
print("media item changed...")
}
// listening for current item status change
self.audioQueueStatusObserver = self.playerQueue?.currentItem?.observe(\.status, options: [.new, .old], changeHandler: {
(playerItem, change) in
if playerItem.status == .readyToPlay {
@snikch
snikch / gist:3661188
Created September 6, 2012 23:16
Find the current top view controller for your iOS application
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}
@codediodeio
codediodeio / database.rules.json
Last active January 28, 2024 19:07
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}