Skip to content

Instantly share code, notes, and snippets.

// Reset current local branch by one commit back
git reset --hard HEAD~
// Push changes to remote
git push origin +branch_name
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
sudo xcodebuild -license accept
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
sudo gem install jazzy
brew install ruby
// Get installed xcode version and swift version
xcodebuild -version
@bdivljak91
bdivljak91 / Activity.showDialog
Created August 30, 2019 08:24
Show dilaog- Activity extension function
fun Activity.showDialog(title: String,
message: String,
positiveButtonFunction: () -> Unit = {},
negativeButtonFunction: () -> Unit = {},
positiveButtonText: String = "YES",
negativeButtonText: String = "NO") {
val builder = AlertDialog.Builder(this)
builder.setTitle(title)
builder.setMessage(message)
@bdivljak91
bdivljak91 / BroadcastReceiverInstance.txt
Last active August 27, 2019 12:04
Simple Bluetooth state monitor broadcast receiver
private val broadCastReceiver = object : BroadcastReceiver() {
override fun onReceive(contxt: Context?, intent: Intent?) {
val action = intent?.action
if (action == BluetoothAdapter.ACTION_STATE_CHANGED) {
val state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR)
when (state) {
BluetoothAdapter.STATE_OFF -> setUIBluetoothOff()
BluetoothAdapter.STATE_ON -> setUIBluetoothOn()
}
@bdivljak91
bdivljak91 / BluetoothStateBroadcastReceiver.txt
Last active April 23, 2021 05:43
Bluetooth state broadcast receiver - Clean Architecture
import android.bluetooth.BluetoothAdapter
import android.content.BroadcastReceiver
import android.content.Intent
import android.content.Context
import dagger.android.AndroidInjection
import io.reactivex.Observable
import io.reactivex.subjects.BehaviorSubject
import javax.inject.Inject