Skip to content

Instantly share code, notes, and snippets.

@frankyonnetti
frankyonnetti / CSS--hex-opacity-values.css
Last active December 8, 2023 05:56
#css Hex Opacity Values
/*
* Hex Opacity Values
*/
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
@Noitidart
Noitidart / Beamoff Tool.iso
Last active October 20, 2022 12:21
Shows how to install OSX 10.10.1 onto Oracle VirtualBox on AMD
@alexwen
alexwen / gist:4b337bc669509a696b5b
Created April 25, 2015 15:59
OkHttp Observable Callback
public Observable<FilesWrapper> download(List<Thing> things) {
return Observable.from(things)
.flatMap(thing -> {
File file = new File(getExternalCacheDir() + File.separator + thing.getName());
if (file.exists()) {
return Observable.just(file);
}
Request request = new Request.Builder().url(thing.getUrl()).build();
@jturolla
jturolla / ActivityRealmRobolectricTest.java
Last active April 21, 2021 06:06
This gist provides a simple example of mocking a Realm database for android in java using Robolectric.
package com.example;
import android.content.Intent;
import android.widget.Button;
import com.example.MockSupport;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@neworld
neworld / howto.md
Last active September 15, 2020 11:32
How to make faster Android build without sacrificing new api lint check

Original solution sacrifices new api lint check.

Here my solution:

int minSdk = hasProperty('minSdk') ? minSdk.toInteger() : 16

apply plugin: 'com.android.application'

android {
 compileSdkVersion 23
@jerrellmardis
jerrellmardis / ExponentialBackoff
Last active June 3, 2019 13:10
Exponential Backoff using Rx.retryWhen()
// retries up to 3 times while exponentially backing off with each retry
.retryWhen(errors ->
errors
.zipWith(
Observable.range(1, MAX_RETRIES), (n, i) -> i
)
.flatMap(
retryCount -> Observable.timer((long) Math.pow(4, retryCount), TimeUnit.SECONDS)
)
)
@roadrunner2
roadrunner2 / 0 Linux-On-MBP-Late-2016.md
Last active July 2, 2024 13:31
Linux on MacBook Pro Late 2016 and Mid 2017 (with Touchbar)

Introduction

This is about documenting getting Linux running on the late 2016 and mid 2017 MPB's; the focus is mostly on the MacBookPro13,3 and MacBookPro14,3 (15inch models), but I try to make it relevant and provide information for MacBookPro13,1, MacBookPro13,2, MacBookPro14,1, and MacBookPro14,2 (13inch models) too. I'm currently using Fedora 27, but most the things should be valid for other recent distros even if the details differ. The kernel version is 4.14.x (after latest update).

The state of linux on the MBP (with particular focus on MacBookPro13,2) is also being tracked on https://github.com/Dunedan/mbp-2016-linux . And for Ubuntu users there are a couple tutorials (here and here) focused on that distro and the MacBook.

Note: For those who have followed these instructions ealier, and in particular for those who have had problems with the custom DSDT, modifying the DSDT is not necessary anymore - se

@frapontillo
frapontillo / giffify.sh
Last active June 18, 2019 12:28
Record Android screen straight to GIF
#!/bin/bash
if [ -z "$1" ]; then
shot_path=$(date +%Y-%m-%d-%H-%M-%S).mp4
else
shot_path="$*"
fi
# Enable show taps on screen
adb shell content insert --uri content://settings/system --bind name:s:show_touches --bind value:i:1
class PostFragment : Fragment() {
private lateinit var bin: CompositeDisposable
private lateinit var vm: PostViewModel
private lateinit var id: String
private lateinit var title: TextView
private lateinit var body: TextView
private lateinit var refreshButton: Button
@elizarov
elizarov / DistinctInTimeWindow.kt
Created April 3, 2018 08:25
Channel operator to send distinct time elements in a specific time window
import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.channels.*
import kotlinx.coroutines.experimental.selects.*
import java.util.concurrent.*
// operator
fun <T> ReceiveChannel<T>.distinctInTimeWindow(time: Long, unit: TimeUnit): ReceiveChannel<T> = produce {
require(time > 0)
consume {
val source = this@distinctInTimeWindow