Skip to content

Instantly share code, notes, and snippets.

View yakivmospan's full-sized avatar

Yakiv Mospan yakivmospan

View GitHub Profile
@JulienArzul
JulienArzul / FadingEdgeRecyclerView.kt
Created July 11, 2018 06:09
RecyclerView class that supports drawing fading edges with clipToPadding=false
package com.julienarzul.android.recyclerview
import android.content.Context
import android.support.v7.widget.RecyclerView
import android.util.AttributeSet
class FadingEdgeRecyclerView : RecyclerView {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
suppose you have two branches: `master` and `huge_feature` and you want to merge `huge_feature` into `master` but partially
you also can not use `git cherry-pick`, you want to have *real merge* but with partially applied patch
1. git checkout master
2. git merge --no-ff --no-commit huge_feature
3. git reset *
4. git add -i // interactively stage what you want https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging
5. git commit
6. git checkout huge_feature
7. git merge -s ours master // this is to be able to merge huge_feature into master later
@MaksimDmitriev
MaksimDmitriev / FileUtils.java
Created January 26, 2018 09:26
PowerMock with System.currentTimeMillis
package sample.com.sample_app;
import android.support.annotation.NonNull;
public class FileUtils {
@NonNull
public static String generateName() {
return Long.toString(System.currentTimeMillis());
}
@magneticflux-
magneticflux- / LiveDataUtils.kt
Last active February 3, 2023 19:08
Helpful Android-Kotlin LiveData utilities
//--------------------------------
// CHECK THE COMMENTS FOR UPDATES!
//--------------------------------
/*
* Copyright (C) 2017 Mitchell Skaggs, Keturah Gadson, Ethan Holtgrieve, Nathan Skelton, Pattonville School District
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@mreichelt
mreichelt / constraint_layout_grow_until_guideline.xml
Last active April 25, 2023 09:00
Example of using ConstraintLayout: The growing view will be only as large as it needs to be - unless it grows too large. Then it will only be as large as the guideline allows.
<?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.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
@jgilfelt
jgilfelt / CurlLoggingInterceptor.java
Created January 9, 2016 15:34
An OkHttp interceptor that logs requests as curl shell commands
/*
* Copyright (C) 2016 Jeff Gilfelt.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@dmytrodanylyk
dmytrodanylyk / ErrorLabelLayout.java
Created January 21, 2015 15:35
Android Error Label
public class ErrorLabelLayout extends LinearLayout implements ViewGroup.OnHierarchyChangeListener {
private static final int ERROR_LABEL_TEXT_SIZE = 12;
private static final int ERROR_LABEL_PADDING = 4;
private TextView mErrorLabel;
private Drawable mDrawable;
private int mErrorColor;
public ErrorLabelLayout(Context context) {
@burgalon
burgalon / AccountAuthenticator.java
Last active July 15, 2023 08:29
Implementing OAuth2 with AccountManager, Retrofit and Dagger
public class AccountAuthenticator extends AbstractAccountAuthenticator {
private final Context context;
@Inject @ClientId String clientId;
@Inject @ClientSecret String clientSecret;
@Inject ApiService apiService;
public AccountAuthenticator(Context context) {
super(context);
@antoniolg
antoniolg / SwipeRefreshActivity.java
Last active July 29, 2019 11:59
An activity that uses a SwipeRefreshLayout as a container for the layout of the classes that extend it.
/*
* Copyright (C) 2014 Antonio Leiva Gordillo.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: