Skip to content

Instantly share code, notes, and snippets.

View install_bundle.sh
FILE=app.apks
if test -f "$FILE"; then
echo "Press enter to delete app.apks"
read wait
rm app.apks
fi
if [ -z "$1" ]
then
echo "No aab file path arguments supplied. Exit."
View Setting scroll position with ReactJS
// Edit from http://blog.vjeux.com/2013/javascript/scroll-position-with-react.html
componentDidMount() {
const node = ReactDOM.findDOMNode(this);
node.scrollTop = node.scrollHeight;
}
componentWillUpdate: function() {
const node = this.getDOMNode();
this.shouldScrollBottom = node.scrollTop + node.offsetHeight === node.scrollHeight;
},
@lekaha
lekaha / SimpleRxBluetoothAdapter.java
Created Sep 18, 2018
SimpleRxBluetoothAdapter is a BT utility with Rx
View SimpleRxBluetoothAdapter.java
package mobile.lekeha.android.bluetoothadapter;
import android.Manifest;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
View GlideConfiguration.kt
@GlideModule
class MyAppGlideModule: AppGlideModule() {
override fun applyOptions(context: Context, builder: GlideBuilder) {
super.applyOptions(context, builder)
builder.setDefaultRequestOptions(
RequestOptions()
.format(DecodeFormat.PREFER_ARGB_8888)
.diskCacheStrategy(DiskCacheStrategy.DATA)
View dslPrintln.kt
fun println(λ: () -> Any) = kotlin.io.println(λ())
@lekaha
lekaha / dsl_marker.kt
Created Jun 29, 2018
Example of using DSL marker annotation
View dsl_marker.kt
@DslMarker
annotation class ReceiptDsl
data class Amount(val total: Int, val tax: Float)
data class Receipt(val title: String, val date: String, val staffName: String, val amount: Amount)
@ReceiptDsl
class AmountBuilder {
var total: Int = 0
var tax: Float = .0f
@lekaha
lekaha / RoundedBottomSheetDialogFragment.kt
Created Jun 23, 2018 — forked from ArthurNagy/RoundedBottomSheetDialogFragment.kt
Rounded modal bottom sheet as seen in new Google products(Tasks, News, etc.)
View RoundedBottomSheetDialogFragment.kt
package com.your.package
import android.app.Dialog
import android.os.Bundle
import com.your.package.R
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
/**
* BottomSheetDialog fragment that uses a custom
@lekaha
lekaha / android dependencies
Last active Jun 21, 2018
dependencies.gradle
View android dependencies
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
ext {
@lekaha
lekaha / RakeFile.rb
Last active May 17, 2016
Build script
View RakeFile.rb
GH_PAGES_DIR = "lekaha.github.io"
desc "Build Jekyll site and copy files"
task :build do
Dir.foreach('notebooks') do |item|
next if item == '.' or item == '..' or Dir.exists?(item) or item[/^(.*\.(md|ipynb_checkpoints|py|tpl)$)?$/i]
Dir.chdir "notebooks/"
sh "ipython nbconvert --config jekyll-post #{item}"
Dir.chdir "../"
end