Skip to content

Instantly share code, notes, and snippets.

View CoderJava's full-sized avatar
🏠
Stay Safe. #WFH

Yudi Setiawan CoderJava

🏠
Stay Safe. #WFH
View GitHub Profile
@CoderJava
CoderJava / example_null_in_json.json
Created July 23, 2018 02:58
Example Null in JSON
{
"address": null
}
@CoderJava
CoderJava / example_json_array_bersarang.json
Created July 23, 2018 08:04
Contoh JSON Array Bersarang
{
"nama": "Yudi Setiawan",
"usia": 23,
"email": "kolonel.yudisetiawan@gmail.com",
"website": [
{
"url": "https://www.majumundurcantik.com",
"description": "Work"
},
{
@CoderJava
CoderJava / git-feature-workflow.md
Created August 11, 2018 02:50 — forked from blackfalcon/git-feature-workflow.md
Git basics - a general workflow

There are many Git workflows out there, I heavily suggest also reading the atlassian.com [Git Workflow][article] article as there is more detail then presented here.

The two prevailing workflows are [Gitflow][gitflow] and [feature branches][feature]. IMHO, being more of a subscriber to continuous integration, I feel that the feature branch workflow is better suited.

When using Bash in the command line, it leaves a bit to be desired when it comes to awareness of state. I would suggest following these instructions on [setting up GIT Bash autocompletion][git-auto].

Basic branching

When working with a centralized workflow the concepts are simple, master represented the official history and is always deployable. With each now scope of work, aka feature, the developer is to create a new branch. For clarity, make sure to use descriptive names like transaction-fail-message or github-oauth for your branches.

@CoderJava
CoderJava / activity_stetho_dev.xml
Last active September 14, 2018 09:30
activity_stetho_dev.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
tools:context=".MainActivity">
<Button
@CoderJava
CoderJava / App.kt
Created September 14, 2018 09:40
App.kt file
class App : Application() {
override fun onCreate() {
super.onCreate()
// Initialization Stetho
Stetho.initializeWithDefaults(this)
}
}
@CoderJava
CoderJava / AndroidManifest.xml
Created September 14, 2018 09:42
AndroidManifest.xml file for Stetho Dev App
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ysn.stethodev">
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
@CoderJava
CoderJava / MainActivity.kt
Last active September 14, 2018 10:07
SharedPreferences debug
// ...
button_shared_preferences.setOnClickListener {
val sharedPreferences = getSharedPreferences("DATA_PREF", Context.MODE_PRIVATE)
val waktu = SimpleDateFormat("dd-MM-yyyy HH:mm:ss", Locale.US)
.format(Date())
sharedPreferences.edit()
.putString("waktu", waktu)
.apply()
}
@CoderJava
CoderJava / MainActivity.kt
Created September 14, 2018 14:40
Network Stetho
// ...
val progressDialog = ProgressDialog(this)
progressDialog.setCancelable(false)
progressDialog.setMessage("Please wait")
button_network.setOnClickListener { _ ->
progressDialog.show()
Observable
.create<Boolean> { emitter ->
val request = Request.Builder()
@CoderJava
CoderJava / WaktuData.kt
Created September 14, 2018 15:24
Waktu Data entity
@Entity
data class WaktuData(
@PrimaryKey(autoGenerate = true) var id: Long?,
@ColumnInfo(name = "waktu") var waktu: String
)
@CoderJava
CoderJava / WaktuDao.kt
Created September 14, 2018 15:29
Waktu DAO
@Dao
interface WaktuDao {
@Query("SELECT * FROM waktudata")
fun getAll(): List<WaktuData>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(waktuData: WaktuData)
}