Skip to content

Instantly share code, notes, and snippets.

@akexorcist
akexorcist / device_list.txt
Last active October 24, 2024 11:01
Android Device List in Firebase Test Lab [30 August 2024] from `gcloud firebase test android models list`
┌─────────────────────┬────────────┬──────────────────────────────────────────┬──────────┬─────────────┬────────────────────────────┬────────────────────────────────────┐
│ MODEL_ID │ MAKE │ MODEL_NAME │ FORM │ RESOLUTION │ OS_VERSION_IDS │ TAGS │
├─────────────────────┼────────────┼──────────────────────────────────────────┼──────────┼─────────────┼────────────────────────────┼────────────────────────────────────┤
│ 1610 │ Vivo │ vivo 1610 │ PHYSICAL │ 1280 x 720 │ 23 │ reduced_stability=23 │
│ AmatiTvEmulator │ Google │ Google TV Amati │ VIRTUAL │ 1080 x 1920 │ 29 │ beta=29 │
│ AndroidTablet270dpi │ Generic │ Generic 720x1600 Android tablet @ 270dpi │ VIRTUAL │ 1600 x 720 │ 30 │
@christopherjohst
christopherjohst / ReorderTableView.swift
Last active March 12, 2021 11:24
Programmatically reordering a table view on macOS using drag and drop. A full example in this Playground, with setup and tear down code. For a detailed guide to how this works, see: https://kitcross.net/reorder-table-views-drag-drop/
import Cocoa
import PlaygroundSupport
class BackgroundView: NSView {
override func draw(_ dirtyRect: NSRect) {
NSColor.underPageBackgroundColor.set()
dirtyRect.fill()
}
}
@vestrel00
vestrel00 / Dagger2SimpleExample.java
Last active October 7, 2021 19:59
A: Dagger.android 2.11 simple example with support for Singleton, PerActivity, PerFragment, and PerChildFragment scopes
// This is a super simplified example of how to use the new dagger.android framework
// introduced in Dagger 2.10. For a more complete, in-depth guide to dagger.android
// read https://proandroiddev.com/how-to-android-dagger-2-10-2-11-butterknife-mvp-part-1-eb0f6b970fd
// For a complete codebase using dagger.android 2.11-2.17, butterknife 8.7-8.8, and MVP,
// see https://github.com/vestrel00/android-dagger-butterknife-mvp
// This example works with Dagger 2.11-2.17. Starting with Dagger 2.11,
// @ContributesAndroidInjector was introduced removing the need to define @Subcomponent classes.
@kunikullaya
kunikullaya / Date+Extension.swift
Created January 18, 2017 05:21
Date Extension for Swift
import Foundation
extension Date {
func toString(format: String = "yyyy-MM-dd") -> String {
let formatter = DateFormatter()
formatter.dateStyle = .short
formatter.dateFormat = format
return formatter.string(from: self)
}
@emotality
emotality / duplicate_line_xcode.md
Last active April 6, 2024 04:23
Xcode - Duplicate Line key binding

NOTE (2022-07-09): Xcode finally added this functionality in Xcode 14, please see release notes here:

New Features in Xcode 14 Beta 3
When editing code, the Edit > Duplicate menu item and its corresponding keyboard shortcut now duplicate the selected text — or the line that currently contains the insertion point, if no text is selected. (8614499) (FB5618491)


Xcode line duplicate

Bind keys to duplicate lines in Xcode

@trobalik
trobalik / FlakyTests.java
Created June 2, 2016 21:49
Flaky Espresso Tests and the RetryTestRule
package com.yourapp.test;
// import statements...
public class FlakyTests {
@Rule
RetryTestRule retry = new RetryTestRule(3); // will attempt each test up to 3 times
@Test
package com.facebook;
import java.util.ArrayList;
import java.util.Collection;
public class AccessTokenCreator {
public static AccessToken createToken(Collection<String> grantedPermissions) {
return new AccessToken("token", "appId", "userId", grantedPermissions,
new ArrayList<String>(), AccessTokenSource.WEB_VIEW, null, null);
@FrancoisBlavoet
FrancoisBlavoet / DiaporamaAdapter.java
Created March 30, 2015 22:09
Helper Class allowing to load multiple images consecutively in the same view with Glide and animate between them.
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.animation.AlphaAnimation;
@mariotaku
mariotaku / ListScrollDistanceCalculator.java
Created October 26, 2014 05:37
Calculate list scroll distance without any modification to ListView and ListAdapter. great for QuickReturn pattern
package org.mariotaku.twidere.util;
import android.view.View;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
/**
* Created by mariotaku on 14/10/22.
*/
public class ListScrollDistanceCalculator implements OnScrollListener {
@steveliles
steveliles / Foreground.java
Last active January 22, 2024 18:06
Class for detecting and eventing whether an Android app is currently foreground or background (requires API level 14+)
package com.sjl.util;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import java.util.List;