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:
#!/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 |
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; |
git --no-pager diff --name-only develop | tr '\n' ',' | sed 's/\(.*\),/\1 /' |
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"
import WatchConnectivity | |
class WatchSessionManager: NSObject, WCSessionDelegate { | |
static let sharedManager = WatchSessionManager() | |
private override init() { | |
super.init() | |
} | |
private let session: WCSession? = WCSession.isSupported() ? WCSession.default : nil |
// 1 - provider creation | |
let provider = MoyaProvider<MyRouter>( | |
manager: AlamofireSessionManagerBuilder().build() | |
) | |
// 2 - session manager builder | |
class AlamofireSessionManagerBuilder { | |
var policies: [String: ServerTrustPolicy]? | |
var configuration = URLSessionConfiguration.default |
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.
// 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) |
fileprivate let badChars = CharacterSet.alphanumerics.inverted | |
extension String { | |
var uppercasingFirst: String { | |
return prefix(1).uppercased() + dropFirst() | |
} | |
var lowercasingFirst: String { | |
return prefix(1).lowercased() + dropFirst() | |
} |