Skip to content

Instantly share code, notes, and snippets.

@reinvanoyen
reinvanoyen / terminal-prompt-git-branch-zsh.md
Last active April 30, 2024 21:16
Add Git Branch Name to Terminal Prompt (MacOS zsh)

Add Git Branch Name to Terminal Prompt (zsh)

Updated for MacOS with zsh

  • Catalina
  • Big Sur
  • Monterey
  • Ventura
  • Sonoma

screenshot

@SUPERCILEX
SUPERCILEX / Async.kt
Created March 27, 2018 06:02
Google Play Services Tasks API with Kotlin Coroutines support
suspend fun <T> Task<T>.await(): T {
if (isComplete) return if (isSuccessful) result else throw exception!!
return suspendCoroutine { c: Continuation<T> ->
addOnSuccessListener { c.resume(it) }
addOnFailureListener { c.resumeWithException(it) }
}
}
fun <T> Deferred<T>.asTask(): Task<T> {
val source = TaskCompletionSource<T>()
@bpolania
bpolania / DataExtensions.swift
Last active January 25, 2024 07:10
Swift Extensions for Data, Int, UInt8, UInt16, and UInt32 types
// MIT License
// Copyright (c) 2018 Boris Polania
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@kitakar5525
kitakar5525 / 00-replacing_MBA_SSD.md
Last active January 30, 2021 19:37
MacBook Air (Early 2015) のSSDを960 EVOに換装したメモです。この環境でArch Linux, macOS, Windowsが動作しました。他のMacでも、High Sierra以上かつ対応するアダプタを使用すればこのgistは参考になると思います。

MacBook Air(Early 2015)でNVMeのSSDに換装した話

MacBook Air (Early 2015) のSSDを960 EVOに換装しました。 MBAをNVMeのSSDに換装したという情報は日本語では少なかったのでメモ書き。 他のMacでも、High Sierra以上かつ対応するアダプタを使用すればこのgistは参考になると思います。

また、さすがにこの環境でWindowsやLinuxを動かしているという人は 検索した範囲ではまだ見つかりませんでしたね。

結論を言うと、macOSはじめWindows 10やArch Linuxでも動いていますが、注意する点がありました:

@LouisCAD
LouisCAD / GooglePlayServices.kt
Created November 23, 2017 16:19
Allows using Google Play Services Task API in Kotlin Coroutines, plus Play Services availability check made easier.
import com.google.android.gms.common.GoogleApiAvailability
import com.google.android.gms.tasks.Task
import splitties.init.appCtx
import kotlin.coroutines.experimental.suspendCoroutine
val googleApiAvailability = GoogleApiAvailability.getInstance()!!
inline val playServicesAvailability get() = googleApiAvailability.isGooglePlayServicesAvailable(appCtx)
@JvmName("awaitVoid")
suspend fun Task<Void>.await() = suspendCoroutine<Unit> { continuation ->
@mathieugerard
mathieugerard / LocalWifiIP.md
Last active September 24, 2023 06:54
Get Local Wifi IP address on iOS and Android

Get Local Wifi IP address on iOS and Android

This Gist provide the function to retrieve the local IP address of the device when connected to the wifi.

iOS

No permission is required from the user to access the information. It uses the getifaddrs method that is not directly part of the public iOS API but it's still perfectly fine to use it and allowed by Apple.

Sources

@piruin
piruin / DrawableCompat.kt
Last active May 3, 2023 13:09
Kotlin Extension for set/get compound Drawable to TextView/EditText/Button as property
/*
* Copyright 2017 Piruin Panichphol
*
* 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
@yatatsu
yatatsu / recyclerview-expand-collapse-transition.md
Last active December 5, 2021 00:11
AndroidのRecyclerViewでアイテムのExpand/Collapseのアニメーションをいい感じにする

問題

AndroidでViewの高さを変えるとき、そこまでこだわらずにシンプルに実装したいときは、 Transition(android.support.transition.Transition)を使うことが多いと思います。

RecyclerViewのアイテムをタップしてそのアイテムの高さを変える、詳細部分の表示非表示を切り替える、 いわゆるExpand/Collapseと言われているような効果を、いい感じのアニメーションで実現したいときにやり方を少し調べたので説明します。

解決方法

@jaredsburrows
jaredsburrows / RxBus1.java
Last active March 16, 2023 10:44
RxBus for RxJava 1 and RxJava 2
import rx.Observable;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;
/**
* @author <a href="mailto:jaredsburrows@gmail.com">Jared Burrows</a>
*/
public final class RxBus {
private final Subject<Object, Object> bus = new SerializedSubject<>(PublishSubject.create());
@nstarke
nstarke / release-android-debuggable.md
Last active April 28, 2024 16:29
How to make a Release Android App debuggable

How to make a Release Android App debuggable

Let's say you want to access the application shared preferences in /data/data/com.mypackage.
You could try to run adb shell and then run-as com.mypackage ( or adb shell run-as com.mypackge ls /data/data/com.mypackage/shared_prefs), but on a production release app downloaded from an app store you're most likely to see:

run-as: Package 'com.mypackage' is not debuggable