Skip to content

Instantly share code, notes, and snippets.

View LouisCAD's full-sized avatar

Louis CAD LouisCAD

View GitHub Profile
@fabiomsr
fabiomsr / ByteArray.kt
Last active April 24, 2024 08:41
ByteArray and String extension to add hexadecimal methods in Kotlin
private val HEX_CHARS = "0123456789ABCDEF".toCharArray()
fun ByteArray.toHex() : String{
val result = StringBuffer()
forEach {
val octet = it.toInt()
val firstIndex = (octet and 0xF0).ushr(4)
val secondIndex = octet and 0x0F
result.append(HEX_CHARS[firstIndex])
@ericclemmons
ericclemmons / example.md
Last active October 13, 2025 15:16
HTML5 <details> in GitHub

Using <details> in GitHub

Suppose you're opening an issue and there's a lot noisey logs that may be useful.

Rather than wrecking readability, wrap it in a <details> tag!

<details>
 Summary Goes Here
package com.actinarium.materialcue.analytics;
import android.app.Application;
import android.support.annotation.NonNull;
import android.util.Log;
import com.actinarium.materialcue.dto.Overlay;
import com.actinarium.materialcue.iab.PremiumStatus;
import com.actinarium.materialcue.iab.PremiumStatusChangeListener;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
@PaulWoitaschek
PaulWoitaschek / tm.xml
Created September 29, 2016 08:28
TM - logm IntelliJ life template for Timber
<template name="tm" value="timber.log.Timber.d($content$);" description="Log method name and its arguments" toReformat="true" toShortenFQNames="true">
<variable name="content" expression="groovyScript(&quot;def params = _2.collect {it + ' = [%s]'}.join(', '); return '\&quot;' + _1 + '() called' + (params.empty ? '' : ' with: ' + params + ',') + '\&quot;' + (_2.empty ? '' : ','+_2.join(','))&quot;, methodName(), methodParameters()) " defaultValue="" alwaysStopAt="false" />
<context>
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
@kentliau
kentliau / open-chrome-tabs-in-safari.scpt
Last active July 16, 2023 15:52 — forked from paulirish/open-chrome-tabs-in-safari.scpt
open all chrome tabs of all windows in safari
tell application "Google Chrome"
set window_list to every window
repeat with the_window in window_list
# For each Window in Chrome, create a new Window in Safari respectively
tell application "Safari"
make new document
activate
@vgaidarji
vgaidarji / AndroidStudio as git difftool, mergetool
Last active March 13, 2020 09:23
Use AndroidStudio as git difftool/mergetool on MacOS (place this inside your ~/.gitconfig).
[merge]
tool = studio
[mergetool "studio"]
prompt = false
cmd = /Applications/Android\\ Studio.app/Contents/MacOS/studio merge $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE") $(cd $(dirname "$BASE") && pwd)/$(basename "$BASE") $(cd $(dirname "$MERGED") && pwd)/$(basename "$MERGED")
trustExitCode = true
[diff]
tool = studio
[difftool "studio"]
prompt = false
@alphamu
alphamu / Android Privacy Policy Template
Created February 9, 2017 03:17
A template for creating your own privacy policy for Android apps. Look for "[" and "<!--" to see where you need to edit this app in order to create your own privacy olicy.
<html>
<body>
<h2>Privacy Policy</h2>
<p>[Individual or Company Name] built the [App Name] app as a [open source | free | freemium | ad-supported | commercial] app. This SERVICE is provided by [Individual or company name] [at no cost] and is intended
for use as is.</p>
<p>This page is used to inform website visitors regarding [my|our] policies with the collection, use, and
disclosure of Personal Information if anyone decided to use [my|our] Service.</p>
<p>If you choose to use [my|our] Service, then you agree to the collection and use of information in
relation with this policy. The Personal Information that [I|we] collect are used for providing and
improving the Service. [I|We] will not use or share your information with anyone except as described
@beyondeye
beyondeye / firebase_coroutine_integration.kt
Created May 27, 2017 20:32
integration of firebase wth kotlin coroutines
/**
* allow to define callback wrappers that are protected from accidental multiple calls to resume/resumeWithException
* Created by daely on 3/30/2017.
*/
class WrappedContinuation<T>(val c: Continuation<T>) : Continuation<T> {
var isResolved = false
override val context: CoroutineContext
get() = c.context
override fun resume(value: T) {
@cbeyls
cbeyls / FragmentArgumentDelegate.kt
Last active October 16, 2018 13:17 — forked from yanngx/FragmentArgumentDelegate.kt
Fragment arguments without hassle !
package be.brol
import android.os.Binder
import android.os.Bundle
import android.os.Parcelable
import android.support.v4.app.BundleCompat
import android.support.v4.app.Fragment
import kotlin.reflect.KProperty
/**
@elizarov
elizarov / StackComputation.kt
Last active September 2, 2020 14:19
Using coroutines to avoid StackOverflowException on recursive calls
import kotlin.coroutines.experimental.*
import kotlin.coroutines.experimental.intrinsics.COROUTINE_SUSPENDED
import kotlin.coroutines.experimental.intrinsics.suspendCoroutineOrReturn
@RestrictsSuspension
abstract class StackComputation {
abstract suspend fun <T> push(block: suspend StackComputation.() -> T): T
}
fun <T> compute(block: suspend StackComputation.() -> T): T =