Skip to content

Instantly share code, notes, and snippets.

@MichaelEvans
MichaelEvans / copr.md
Created Jan 13, 2020 — forked from gvaughn/copr.md
git copr alias
View copr.md

I'd like to share some git aliases that you might find useful if you handle pull requests from others.

Add these to your ~/.gitconfig in the [alias] section:

copr = "!f() { git fetch -fu origin refs/pull/$1/head:pr-$1; git checkout pr-$1; } ; f"
prunepr = "!git for-each-ref refs/heads/pr-* --format='%(refname:short)' | while read ref ; do git branch -D $ref ; done"

Now you can "git copr #{pr_number}" (check out pull request is the mnemonic) and it will pull down the PR in a local branch of pr-#{pr_number} and check it out for you. To do it right, you must pronounce it "Copper" with a James Cagney gangster accent.

@MichaelEvans
MichaelEvans / copr.md
Created Jan 13, 2020 — forked from gvaughn/copr.md
git copr alias
View copr.md

I'd like to share some git aliases that you might find useful if you handle pull requests from others.

Add these to your ~/.gitconfig in the [alias] section:

copr = "!f() { git fetch -fu origin refs/pull/$1/head:pr-$1; git checkout pr-$1; } ; f"
prunepr = "!git for-each-ref refs/heads/pr-* --format='%(refname:short)' | while read ref ; do git branch -D $ref ; done"

Now you can "git copr #{pr_number}" (check out pull request is the mnemonic) and it will pull down the PR in a local branch of pr-#{pr_number} and check it out for you. To do it right, you must pronounce it "Copper" with a James Cagney gangster accent.

@MichaelEvans
MichaelEvans / Gemfile
Created Jul 26, 2016 — forked from neoeno/Gemfile
Pokemon Go Slack Bot
View Gemfile
source "https://rubygems.org"
gem "httparty"
gem "geocoder"
gem "slack-poster"
@MichaelEvans
MichaelEvans / appcompat.diff
Last active Mar 27, 2016
Changelog for Support Libraries v23.2.0 -> v24.0.0-alpha1
View appcompat.diff
diff -U 0 -N appcompat-v7-23.2.0_ff0f8a1a/android.support.v7.app.AppCompatDelegateImplV7$PanelFeatureState appcompat-v7-24.0.0-alpha1_4f276de6/android.support.v7.app.AppCompatDelegateImplV7$PanelFeatureState
--- appcompat-v7-23.2.0_ff0f8a1a/android.support.v7.app.AppCompatDelegateImplV7$PanelFeatureState 1969-12-31 19:00:00.000000000 -0500
+++ appcompat-v7-24.0.0-alpha1_4f276de6/android.support.v7.app.AppCompatDelegateImplV7$PanelFeatureState 2016-03-09 19:28:22.000000000 -0500
@@ -0,0 +1,5 @@
+public final class android.support.v7.app.AppCompatDelegateImplV7$PanelFeatureState {
+ public boolean qwertyMode;
+ public boolean hasPanelItems();
+ public void clearMenuPresenters();
+}
diff -U 0 -N appcompat-v7-23.2.0_ff0f8a1a/android.support.v7.view.WindowCallbackWrapper appcompat-v7-24.0.0-alpha1_4f276de6/android.support.v7.view.WindowCallbackWrapper
@MichaelEvans
MichaelEvans / TimeDialog.java
Created Jan 7, 2016
Wrapper on {@code TimePickerDialog} to control min and max times.
View TimeDialog.java
/**
* Wrapper on {@code TimePickerDialog} to control min and max times.
*/
public class TimeDialog extends TimePickerDialog {
private Time mMinTime;
private Time mMaxTime;
public static TimeDialog create(Context context, OnTimeSetListener callBack,
int hour, int minute, boolean is24HourView, long min, long max) {
Time time = getBoundedTime(hour, minute, min, max);
return new TimeDialog(context, callBack, time.hour, time.minute,
View RetryWithBackOffStrategy.cs
// Licensed under the MIT license with <3 by GitHub
/// <summary>
/// An exponential back off strategy which starts with 1 second and then 4, 9, 16...
/// </summary>
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
public static readonly Func<int, TimeSpan> ExponentialBackoff = n => TimeSpan.FromSeconds(Math.Pow(n, 2));
/// <summary>
/// Returns a cold observable which retries (re-subscribes to) the source observable on error up to the
View RxponetialBackoff
/**
* @param intervalMs The base interval to start backing off from. The function is: attemptNum^2 * intervalMs
* @param retryAttempts The max number of attempts to retry this task or -1 to try MAX_INT times,
*/
public static <T> Observable.Transformer<T, T> backoff(final long intervalMs, final int retryAttempts) {
return new Observable.Transformer<T, T>() {
@Override
public Observable<T> call(final Observable<T> observable) {
return observable.retryWhen(
View 1 search_bar.xml
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
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
View gist:2dbca9c68fda99ac27e0
ffmpeg -i ${filename} -vf scale=300:-1,format=rgb8,format=rgb24 -r 15 destination.gif
View Readme.md

You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example: