Skip to content

Instantly share code, notes, and snippets.

View saroar's full-sized avatar
🏠
Working from home

Saroar Khandoker saroar

🏠
Working from home
View GitHub Profile
@saroar
saroar / mac-setup-redis.md
Created May 18, 2019 06:37 — forked from tomysmile/mac-setup-redis.md
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@saroar
saroar / benchmarkSwift.swift
Created September 29, 2019 09:10 — forked from minikin/benchmarkSwift.swift
Benchmark Swift code execution
/*
The former will log out the time required for a given section of code, with the latter returning that as a float.
Read more : http://stackoverflow.com/questions/25006235/how-to-benchmark-swift-code-execution
*/
func printTimeElapsedWhenRunningCode(title:String, operation:()->()) {
let startTime = CFAbsoluteTimeGetCurrent()
operation()
@saroar
saroar / xcode-how-to-backtrace.md
Created May 5, 2020 08:47 — forked from weissi/xcode-how-to-backtrace.md
xcode-how-to-backtrace.md

@saroar
saroar / nginx.conf
Created June 14, 2020 07:52 — forked from nrollr/nginx.conf
NGINX config for SSL with Let's Encrypt certs
# UPDATED 17 February 2019
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
listen [::]:80;
server_name www.domain.com domain.com;
return 301 https://$host$request_uri;
}
# SSL configuration
@saroar
saroar / letsencrypt_2020.md
Created June 14, 2020 08:11 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@saroar
saroar / combine-retry.md
Created September 1, 2020 19:23 — forked from dry1lud/combine-retry.md
Retry operation in Swift/Combine.

There is a function .retry() in Combine that helps to retry a request. Although it is not enough just to call retry() to achieve retring logic. The retry() function does not do another request but it re-subscribes only to a publisher. To make another request the tryCatch() might be used. In the code below if the first call fails there are three attempts to retry (retry(3)):

import UIKit
import Combine
import PlaygroundSupport

enum CustomNetworkingError: Error {
    case invalidServerResponse
}
@saroar
saroar / Update .gitignore
Created October 12, 2020 16:23 — forked from c33k/Update .gitignore
Updating .gitignore and cleaning the cache
//First commit any outstanding code changes, and then, run this command:
git rm -r --cached .
//This removes any changed files from the index(staging area), then just run:
git add .
//Commit
git commit -m "Atualizando .gitignore para..."
@saroar
saroar / UIStoryboard.swift
Created June 7, 2021 12:10 — forked from alexj70/UIStoryboard.swift
UIStoryboard extension
import UIKit
extension UIStoryboard {
/// Main storyboard
public var main: UIStoryboard {
return UIStoryboard(name: "Main", bundle: nil)
}
/// Instantiates and returns the view controller with the specified identifier.
///
/// - Parameter identifier: uniquely identifies equals to Class name
@saroar
saroar / build-xcframework.sh
Created June 17, 2021 07:48 — forked from quangDecember/build-xcframework.sh
Build XCFramework (universal) framework, create new Aggregate target, add to New Run Script Phase
env > env.txt
instruments -s devices > devices.txt
#! /bin/sh -e
# This script demonstrates archive and create action on frameworks and libraries
# Based on script by @author Boris Bielik
# Release dir path
OUTPUT_DIR_PATH="${PROJECT_DIR}/XCFramework"
function archivePathSimulator {
@saroar
saroar / sourcery-generate-app-secrets.sh
Created September 11, 2021 17:39 — forked from lordcodes/sourcery-generate-app-secrets.sh
Read secrets into your iOS project from xcconfig files and then use Sourcery to generate a source file to use them within your code.
#!/bin/bash
# Generate list of arguments to pass to Sourcery
function sourceryArguments {
# Environment variables from BuildConfig to map into AppSecrets
local arguments=(
"CHAT_API_CLIENT_SECRET" "ANALYTICS_WRITE_KEY"
)
local combinedArgs