This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.annotation.IdRes | |
import androidx.fragment.app.* | |
/** | |
* Push [Fragment] into container that gets added to back-stack and later be popped by popping the | |
* back-stack. | |
* | |
* Sample Usage: | |
* ``` | |
* childFragmentManager.push(myFragment, R.id.childContainer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import io.reactivex.Observable | |
import okhttp3.ResponseBody | |
import okio.Okio | |
import retrofit2.Response | |
import java.io.File | |
private val <T> Response<T>.attachmentFileName | |
get() = headers()["Content-Disposition"] | |
?.removePrefix("attachment; filename=") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TokenGenerator { | |
private var canObtainToken = true | |
private var token = "TOKEN" | |
fun obtainToken(): String { | |
if (!canObtainToken) { | |
throw Error() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun <T> tryOptional(expression: () -> T): T? { | |
return try { | |
expression() | |
} catch (ex: Throwable) { | |
null | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TokenGenerator { | |
internal struct TokenError: Error {} | |
private var canObtainToken = true | |
private var token = "TOKEN" | |
func obtainToken() throws -> String { | |
guard canObtainToken else { | |
throw TokenError() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class DragAndDropViewController: UIViewController, UIGestureRecognizerDelegate { | |
private var sourceView: UIView! | |
private var dropArea: UIView! | |
private var objectSize = CGSize(width: 100, height: 100) | |
private var originalPosition = CGPoint.zero | |
override func loadView() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RxCocoa | |
import RxSwift | |
import SocketIO | |
final class MySocketManager { | |
struct Relays { | |
// Custom events: | |
/// User properties updated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UICollectionView { | |
// MARK: - UICollectionView scrolling/datasource | |
/// Last Section of the CollectionView | |
var lastSection: Int { | |
return numberOfSections - 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rl = require('readline').createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}) | |
let question = | |
'\033c' + // Clear screen | |
'\n'.repeat(process.stdout.rows - 4) + // Move prompt to the bottom | |
'Gob\'s Program: Y/N?\n? ' | |
rl.question(question, (answer) => { | |
if (answer.trim().toLowerCase() === 'y') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# !bin/bash | |
docker-ssh () | |
{ | |
if [[ $1 ]]; then | |
docker exec -it $1 bash | |
else | |
echo "Usage: docker-ssh <container_id>" | |
fi | |
} |
NewerOlder