Skip to content

Instantly share code, notes, and snippets.

@cmathew
cmathew / AndroidLintJodaExample.kt
Created September 12, 2023 17:19
Example of providing a stubbed dependency to an Android Lint unit test
// Define Joda-Time stub
val JODA_STUB = TestFiles.kotlin(
"""
package org.joda.time
class DateTime(
private val moment: Int,
private val zone: String
) {
companion object {
@cmathew
cmathew / WarnLocalDateConversion.kt
Created September 12, 2023 15:25
Android Lint code to remind developers that DateTime.toLocalDate is a lossy operation
class WarnLocalDateConversion : Detector(), SourceCodeScanner {
override fun getApplicableMethodNames(): List<String> = listOf("toLocalDateTime", "toLocalDate")
override fun visitMethodCall(context: JavaContext, node: UCallExpression, method: PsiMethod) {
val receiverClassName = (node.receiverType as PsiClassReferenceType).reference.qualifiedName
if (receiverClassName == "org.joda.time.DateTime") {
context.report(
WARN_LOCAL_DATE_CONVERSION,
node,
context.getLocation(node),
@u0705666
u0705666 / suspend-api-single.kt
Created June 8, 2023 04:41
suspend api single call
@Inject lateinit var suspendApi: SuspendApi
shownScope.launch {
view.showSearchLoading()
val result = suspendApi.getCategorizedAssetsSearch(searchStr, assetCategory?.categoryIdentifier)
view.hideSearchLoading()
when (result) {
is ApiResult.Success -> {
view.replaceListItems(getAssetListItem(result.data.categorizedAssets))
@u0705666
u0705666 / rxjava-combined-api-call-example.kt
Created June 8, 2023 04:39
rxjava-combined-api-call-example
private fun fetchAccounts() {
val externalAccountLinkStatusObservable = linkCoordinator.linkStatusObservable
val wealthFrontAccountObservable = accountRepository.wealthfrontAccountObservable
val wealthFrontAccountRequestsObservable = accountRequestsRepository.wealthfrontAccountRequestObservable
val calloutObservable = calloutsRepository.getCalloutsObservable(AccountListSection::class.java)
autoDisposer.autoDispose(
combineLatest(
externalAccountLinkStatusObservable,
wealthFrontAccountObservable,
@u0705666
u0705666 / rxjava-api-call-example.java
Created June 8, 2023 04:38
rxjava-api-call-example
autoDispose(
api.getCategorizedAssetsSearch(searchStr, assetCategory?.categoryIdentifier)
.observeOn(mainThread())
.doOnSubscribe { view.showSearchLoading() }
.doOnTerminate { view.hideSearchLoading() }
.subscribe(
{
view.replaceListItems(getAssetListItem(it.categorizedAssets))
},
{
@xanathar
xanathar / launch.json
Created September 17, 2020 18:16
launch.json to debug Rust with VsCode
{
// The following are sample configurations for common case scenarios of debugging
// Rust in Visual Studio Code
//
// For syntax, visit: https://go.microsoft.com/fwlink/?linkid=830387
//
"version": "0.2.0",
"configurations": [
{
"name": "Launch an application",
@danieldogeanu
danieldogeanu / RenameGitBranch.md
Last active November 16, 2024 08:03
How to rename your Git master branch to main.

To rename your Git master branch to main, you must do the following steps:

  1. Navigate to your repository in the command line and issue the following commands: - git branch -m master main - git push -u origin main

  2. Change your default branch on GitHub by going to your GitHub repository in your browser, and navigate to Settings > Branches and click on the dropdown and switch from master to main and click Update (this will only show if you have two or more branches). The main branch is now your default branch.

  3. Update the tracking of the branch from your command line with the following command: - git branch -u origin/main main

@xorxornop
xorxornop / launch.json
Created March 25, 2018 04:31
Launch configuration for debugging Rust code inside VS Code with LLDB
{
// Launch configuration for debugging Rust code inside VS Code with LLDB
// This configuration is used by the extension 'LLDB Debugger'
//
// The necessary extension may be downloaded at: https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb
// Alternatively, the repository for it may be found at: https://github.com/vadimcn/vscode-lldb.git
"version": "0.1.0",
"configurations": [
{
@Pulimet
Pulimet / AdbCommands
Last active November 16, 2024 07:40
Adb useful commands list
Hi All!
I've recently launched a tool that wraps many of the commands here with a user interface. This desktop application is currently available for macOS. There's a roadmap outlining planned features for the near future.
Feel free to request any features you'd like to see, and I'll prioritize them accordingly.
One of the most important aspects of this application is that every command executed behind the scenes is displayed in a special log section. This allows you to see exactly what’s happening and learn from it.
Here's the link to the repository: https://github.com/Pulimet/ADBugger
App Description:
ADBugger is a desktop tool designed for debugging and QA of Android devices and emulators. It simplifies testing, debugging, and performance analysis by offering device management, automated testing, log analysis, and remote control capabilities. This ensures smooth app performance across various setups.
@Jim-Bar
Jim-Bar / YUV_formats.md
Last active October 30, 2024 13:14
About YUV formats

About YUV formats

First of all: YUV pixel formats and Recommended 8-Bit YUV Formats for Video Rendering. Chromium's source code contains good documentation about those formats too: chromium/src/media/base/video_types.h and chromium/src/media/base/video_frame.cc (search for RequiresEvenSizeAllocation(), NumPlanes() and those kinds of functions).

YUV?

You can think of an image as a superposition of several planes (or layers in a more natural language). YUV formats have three planes: Y, U, and V.

Y is the luma plane, and can be seen as the image as grayscale. U and V are reffered to as the chroma planes, which are basically the colours. All the YUV formats have these three planes, and differ by the different orderings of them.