Skip to content

Instantly share code, notes, and snippets.

@mrexmelle
mrexmelle / TrackerMain.kt
Last active April 14, 2020 09:17
An example of how to track the percentage of multimedia file being played.
import java.util.BitSet
const val MIN = 6
const val SEC = 11
fun countSec(m: Int, s: Int): Int {
return (60 * m) + s
}
@diegohkd
diegohkd / android_draw_ui.md
Last active April 28, 2020 10:44
This is a simple code to help understand how Android draws the UI
<?xml version="1.0" encoding="utf-8"?>
<example.com.exampledrawview.CustomLinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">

    <example.com.exampledrawview.CustomTextView
@MoshDev
MoshDev / installRun.gradle
Last active June 9, 2023 15:41
Install and Run Android App Using Gradle Task
//Place this script inside your application module build.gradle
//It will create a new task(s) based on your application variants within (run) group
//sample: ./gradlew installRunDebug
//sample: ./gradlew installRunStagDebug
project.afterEvaluate {
android.applicationVariants.all { variant ->
task "installRun${variant.name.capitalize()}"(type: Exec, dependsOn: "install${variant.name.capitalize()}", group: "run") {
commandLine = ["adb", "shell", "monkey", "-p", variant.applicationId + " 1"]
doLast {
@kyawkyaw
kyawkyaw / 1. Usage.md
Created December 18, 2015 09:00
How to track the progress of any OkHttp request body. Licence: MIT

How to track the progress of any OkHttp request body

Requires OkHttp >= 2.1.0 if you need to work with multipart request bodies. Lower versions don’t report the content length for the body, but the sum of the sizes of the parts is a pretty good approximation.

// TODO: Build a request body
RequestBody body = null;
@nesquena
nesquena / ItemClickSupport.java
Last active April 29, 2024 16:23
Click handling for RecyclerView
/*
Source: http://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/
USAGE:
ItemClickSupport.addTo(mRecyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() {
@Override
public void onItemClicked(RecyclerView recyclerView, int position, View v) {
// do it
}
});
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active May 19, 2024 17:40
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@briankung
briankung / The Pragmatic Programmer Chapter 4: Pragmatic Paranoia.md
Last active March 8, 2023 22:31
The Pragmatic Programmer Chapter 4: Pragmatic Paranoia

Pragmatic Paranoia

This chapter is about defensive coding practices, both against users of your software and against yourself. Pragmatic Programmers, after all, understand that everyone makes mistakes, even themselves.

Design by Contract

This confused the shit out of me. I wasn't entirely sure what the difference was between a contract and a unit test.

Contracts are introduced in the context of employment contracts. That is, before any work is done, the responsibilities of both parties are defined, as well as the consequences of failing. Contracts in programming are similar. As I mentioned before, I wasn't able to make a strong distinction between contracts and unit tests (given some condition, when some event, then this should happen, though I may be confusing this with [BDD][bdd]). It's all a bit jumbled in my head.