Skip to content

Instantly share code, notes, and snippets.

View SergLam's full-sized avatar
😊
Try to make your code better!

Serhii Liamtsev SergLam

😊
Try to make your code better!
View GitHub Profile
@SergLam
SergLam / script.sh
Created August 6, 2020 15:40
Google protobuf installation on Mac
$wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.bz2
$tar xvf protobuf-2.5.0.tar.bz2
$cd protobuf-2.5.0
$./configure CC=clang CXX=clang++ CXXFLAGS='-std=c++11 -stdlib=libc++ -O3 -g' LDFLAGS='-stdlib=libc++' LIBS="-lc++ -lc++abi"
$make -j 4
$sudo make install
$protoc --version
@SergLam
SergLam / AsynchronousBlockOperation.swift
Last active September 29, 2023 17:37 — forked from CanTheAlmighty/AsynchronousBlockOperation.swift
Subclass of (NS)Operation to make it asynchronous in Swift 5, also providing a Block-based alternative.
//
// AsynchronousBlockOperation.swift
//
// Created by Jose Canepa on 12/13/17.
// Copyright © 2017 Jose Canepa. All rights reserved.
//
import Foundation
/// Block based version of the AsynchronousOperation
@SergLam
SergLam / ShowTime.swift
Created April 1, 2020 11:45
Hightlight touches for iOS (UIKit) - like Android dev mode "show touches" option
import UIKit
/// ShowTime displays your taps and swipes when you're presenting or demoing.
/// Change the options to customise ShowTime.
public final class ShowTime: NSObject {
/// Defines if and when ShowTime should be enabled.
///
/// - always: ShowTime is always enabled.
/// - never: ShowTime is never enabled.
@SergLam
SergLam / UIDevice+Ext.swift
Created March 26, 2020 10:09
Swift - get device IP address
import UIKit
extension UIDevice {
/**
Returns device ip address. Nil if connected via celluar.
*/
func getIP() -> String? {
var address: String?
@SergLam
SergLam / Steps.swift
Last active September 29, 2024 11:35
XCode quick install / update
// Original video tutorial
// https://www.youtube.com/watch?v=6iSuc2vxT8g
// 0. Install a Homebrew
// https://brew.sh/
// 1. Install Ruby to your Mac
// brew install ruby
// 2. Install aria2 tool
@SergLam
SergLam / ShareFactory.swift
Last active February 18, 2020 11:11
Sharing to social networks using Swift
import FacebookShare
import FBSDKShareKit
import UIKit
protocol ShareFactoryDelegate: class {
func didFailWithError(_ error: String)
func didCompleteSharing()
}
@SergLam
SergLam / CustomAlamofireManager.swift
Created January 30, 2020 15:14
Alamofire - custom session manager
import Alamofire
import Foundation
final class CustomAlamofireManager: Alamofire.SessionManager {
private static let requestTimeOutTimeInterval: TimeInterval = {
#if DEBUG
return 30.0
#else
return 120.0
@SergLam
SergLam / Palindrome.swift
Last active January 24, 2020 10:12
Swift - palindrome finding functions
import UIKit
import PlaygroundSupport
let page = PlaygroundPage.current
page.needsIndefiniteExecution = true
func palindrome(for string: String) -> Bool {
let arr = Array(string.lowercased())
// NOTE: from the natural language point of view empty string - is not a palindrome
@SergLam
SergLam / UIApplication+Environment.swift
Created January 16, 2020 18:56
Swift - check iOS app environment (debug OR TestFlight build) at runtime
import UIKit
extension UIApplication {
// MARK: Public
func isRunningInTestFlightEnvironment() -> Bool {
if isSimulator() {
return false
} else {
if isAppStoreReceiptSandbox() && !hasEmbeddedMobileProvision() {
@SergLam
SergLam / locale-capital.json
Created January 15, 2020 15:00
Locale - country capital city datasheet (usefull for map centring)
[
{"locale_key": "bs", "Marathi": "Bosnian",
"capital": {
"name": "New Delhi",
"latitude": 28.6357600,
"longitude": 77.2244500
}
},
{"locale_key": "ee_TG", "Marathi": "Ewe (Togo)",
"capital": {