Skip to content

Instantly share code, notes, and snippets.

View MRezaNasirloo's full-sized avatar
👨‍💻

M. Reza Nasirloo MRezaNasirloo

👨‍💻
View GitHub Profile
package com.mindorks.snaphelperexample.ui.common;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.LinearSnapHelper;
import android.support.v7.widget.OrientationHelper;
import android.support.v7.widget.RecyclerView;
import android.view.View;
@BoD
BoD / .travis.yml
Last active October 27, 2020 13:25
Travis build file for Android: the whole file
language: java
dist: trusty
jdk: oraclejdk8
before_cache:
# Do not cache a few Gradle files/directories (see https://docs.travis-ci.com/user/languages/java/#Caching)
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
@marszall87
marszall87 / docker-compose-install.sh
Created September 25, 2015 13:14
Simple script for installing latest Docker Compose on CoreOS >= 717.0.0
#!/bin/bash
mkdir -p /opt/bin
curl -L `curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r '.assets[].browser_download_url | select(contains("Linux") and contains("x86_64"))'` > /opt/bin/docker-compose
chmod +x /opt/bin/docker-compose
@nickbutcher
nickbutcher / 1 search_bar.xml
Last active March 26, 2022 10:03
Demonstrating morphing a search icon into a search field. To do this we use an AnimatedVectorDrawable (https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html) made up of two paths. The first is the search icon (as a single line) the second is the horizontal bar. We then animate the 'trimPathStart' property …
<?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
@Nkawu
Nkawu / ATtiny85 PWM.ino
Last active April 24, 2022 15:12
PWM on the ATtiny85 with a complementary waveform & dead time
void setup()
{
// DDRB – Port B Data Direction Register (p64)
// 8-bit R/W [ : :DDB5:DDB4:DDB3:DDB2:DDB1:DDB0]
// PORTB = 1<<DDB1 | 1<<DDB0;
pinMode(0, OUTPUT); // 1<<DDB0: PWM output on pin 0 (^OC1A)
pinMode(1, OUTPUT); // 1<<DDB1: PWM output on pin 1 (OC1A)
// TCCR1 - Timer/Counter1 Control Register (p89)
// 8-bit R/W: [CTC1:PWM1A:COM1A1:COM1A0:CS13:CS12:CS11:CS10]
@pyricau
pyricau / IMMLeaks.java
Last active June 5, 2022 22:46
"Fix" for InputMethodManager leaking the last focused view: https://code.google.com/p/android/issues/detail?id=171190
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.ContextWrapper;
import android.os.Bundle;
import android.os.Looper;
import android.os.MessageQueue;
import android.util.Log;
import android.view.View;
import android.view.ViewTreeObserver;
#!/bin/bash
set -e
# A precommit hook that uses spotless to format only staged files
# It also supports partially stage files using the following steps:
# 1. It stashed all the unstaged changes and then runs spotlessApply
# 2. After spotless apply is finished it applyes the stashed changes back on the code (that is also formatted/changed by spotless)
# 3. All the files that have conflicts due to the stash apply, it merges the conflict with the changes that are coming from the stash to not loose any new changes that were not staged
@JakeWharton
JakeWharton / Truss.java
Last active June 9, 2023 07:35
Extremely simple wrapper around SpannableStringBuilder to make the API more logical and less awful. Apache 2 licensed.
import android.text.SpannableStringBuilder;
import java.util.ArrayDeque;
import java.util.Deque;
import static android.text.Spanned.SPAN_INCLUSIVE_EXCLUSIVE;
/** A {@link SpannableStringBuilder} wrapper whose API doesn't make me want to stab my eyes out. */
public class Truss {
private final SpannableStringBuilder builder;
private final Deque<Span> stack;
@molivier
molivier / gist:271bba5d67de1583a8e3
Last active January 3, 2024 09:57
Set $GOPATH on Mac OSX : bash_profile
# Edit ~/.bash_profile
export GOPATH=/Users/$USER/go
export PATH=$GOPATH/bin:$PATH
# Reload profile : source ~/.bash_profile
@TWiStErRob
TWiStErRob / OkHttpProgressGlideModule.java
Last active January 31, 2024 13:37
Full POC for showing progress of loading in Glide v3 via OkHttp v2
// TODO add <meta-data android:value="GlideModule" android:name="....OkHttpProgressGlideModule" />
// TODO add <meta-data android:value="GlideModule" tools:node="remove" android:name="com.bumptech.glide.integration.okhttp.OkHttpGlideModule" />
// or not use 'okhttp@aar' in Gradle depdendencies
public class OkHttpProgressGlideModule implements GlideModule {
@Override public void applyOptions(Context context, GlideBuilder builder) { }
@Override public void registerComponents(Context context, Glide glide) {
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(createInterceptor(new DispatchingProgressListener()));
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}