Skip to content

Instantly share code, notes, and snippets.

View emrcftci's full-sized avatar
📲
Focusing

Emre Çiftçi emrcftci

📲
Focusing
View GitHub Profile
@emrcftci
emrcftci / generate_storyboard_names.sh
Last active November 9, 2023 15:38
Shitty script to generate storyboard names.
#!/bin/sh
# https://gist.github.com/cci-emciftci/0072ecdae6be33773cb5a7f47a38fa1e
# Internal Field Separator(IFS) doc
# https://www.baeldung.com/linux/ifs-shell-variable
echo 'Checking changes...'
# Line number in UIStoryboard+Additions.swift to be changed.
LINE_TO_BE_CHANGED=24
@mob-sakai
mob-sakai / _README.md
Last active May 8, 2024 08:10
Run shell script on gist

Run shell script on gist

Shells that support process substitution such as bash and zsh allow to run shell script on gist as follows.

# With curl:
bash <(curl -sL ${GIST_URL}) args...

# With wget:
pragma solidity >=0.4.22 <0.6.0;
interface tokenRecipient {
function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external;
}
contract TokenERC20 {
// Public variables of the token
string public name;
string public symbol;
@marcelblijleven
marcelblijleven / git diff comma separated files.sh
Created December 9, 2019 09:23
Comma separated files with git diff
git --no-pager diff --name-only develop | tr '\n' ',' | sed 's/\(.*\),/\1 /'
@danielmartin
danielmartin / BetterXcodeJumpToCounterpartSwift.org
Last active March 9, 2024 02:00
Add support for a better Xcode's Jump to Next Counterpart in Swift

If you work on a Swift project that follows the Model-View-ViewModel (MVVM) architecture or similar, you may want to jump to counterpart in Xcode from your view to your model, and then to your view model. (ie. by using Ctrl+Cmd+Up and Ctrl+Cmd+Down).

You can do this in recent versions of Xcode by setting a configuration default.

From a terminal, just type this command and press Enter:

defaults write com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View"
@filsv
filsv / WatchSessionManager.swift
Last active April 8, 2023 21:33
WatchConnectivity Singleton (Swift 5+, iOS+WatchOS Targets) + How to (comment below)
import WatchConnectivity
class WatchSessionManager: NSObject, WCSessionDelegate {
static let sharedManager = WatchSessionManager()
private override init() {
super.init()
}
private let session: WCSession? = WCSession.isSupported() ? WCSession.default : nil
@RodrigoLGuimaraes
RodrigoLGuimaraes / AlamofireSessionManagerBuilder.swift
Last active February 1, 2022 08:07
Creation of a Moya provider with SSL pinning
// 1 - provider creation
let provider = MoyaProvider<MyRouter>(
manager: AlamofireSessionManagerBuilder().build()
)
// 2 - session manager builder
class AlamofireSessionManagerBuilder {
var policies: [String: ServerTrustPolicy]?
var configuration = URLSessionConfiguration.default
@4np
4np / WKWebView-and-AVPlayer.md
Created April 5, 2019 11:17
Detecting Video Playback inside a WKWebView

Detecting Video Playback inside a WKWebView

Observing video playback inside a black-boxed WKWebView is difficult as you don't have direct access to the video player.

Another complicating matter is that depending on the video, the video might be played using a HTML5 video player, while others might launch the native AVPlayerViewController for playback. While it might be possible to detect HTML5 based playback by injecting custom JavaScript using a WKUserContentController, this is not the approach we will follow in the document as these depend on what HTML5 Video Player is involved and is, as such, not a generic solution.

Making sure AVKit is used

// without turtle drawing a hexagon is math heavy and not trivial to modify
let numberOfSides: CGFloat = 6
let radiusOuterCircle: CGFloat = bounds.width
let sideLength = radiusOuterCircle / 2
let theta = (CGFloat.pi * 2) / numberOfSides
let centerX = sideLength / 2
let centerY = sideLength / 2
let initialPoint = CGPoint(x: radiusOuterCircle * cos(2 * CGFloat.pi * 0/numberOfSides + theta) + centerX, y: radiusOuterCircle * sin(2 * CGFloat.pi * 0/numberOfSides + theta) + centerY)
@reitzig
reitzig / Camelizer.swift
Created February 22, 2018 17:26
Convert Swift strings to camel case
fileprivate let badChars = CharacterSet.alphanumerics.inverted
extension String {
var uppercasingFirst: String {
return prefix(1).uppercased() + dropFirst()
}
var lowercasingFirst: String {
return prefix(1).lowercased() + dropFirst()
}