This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun DictionaryEntries(words: List<Word>) { | |
Column(modifier = Modifier.padding(all = 16.dp), verticalArrangement = Arrangement.spacedBy(32.dp)) { | |
for (word in words) { | |
Card(elevation = 2.dp, modifier = Modifier.fillMaxWidth(), shape = RoundedCornerShape(2.dp)) { | |
DictionaryEntry(word.rubies) | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// java.lang.ClassNotFoundException | |
// java.lang.NoClassDefFoundError | |
// Could not find or load main class | |
// https://youtrack.jetbrains.com/issue/KT-29082 | |
task execute(type: JavaExec) { | |
main = "com.github.MainKt" | |
classpath = objects.fileCollection().from( | |
tasks.named("compileKotlin"), | |
tasks.named("compileJava"), // if you have java sources or generated java sources | |
configurations.named("runtimeClasspath") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private const val SHOW_GREETING_TOAST = "SHOW_GREETING_TOAST" | |
// alternatively, make this public for other activities to use | |
private var Intent.showGreetingToast: Boolean | |
set(value) { putExtra(SHOW_GREETING_TOAST, value) } | |
get() = getBooleanExtra(SHOW_GREETING_TOAST, false) | |
class MyActivity : Activity() { | |
companion object { | |
fun newIntent(context: Context, showGreetingToast: Boolean): Intent { | |
val intent = Intent(context, MyActivity::class.java) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T> Observable<T>.toColdSingleSubscribeable(): Observable<T> { | |
return ColdObservableSingleSubscriberProxy(this) | |
} | |
class ColdObservableSingleSubscriberProxy<T>(private val observable: Observable<T>) : Observable<T>() { | |
private val hasBeenSubscribed = AtomicBoolean(false) | |
override fun subscribeActual(observer: Observer<in T>) { | |
if (hasBeenSubscribed.compareAndSet(false, true)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun hideKeyboard() { | |
currentFocus?.windowToken?.let { | |
val imm = applicationContext?.getSystemService(InputMethodManager::class) | |
imm?.hideSoftInputFromWindow(it, InputMethodManager.HIDE_NOT_ALWAYS) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"math/rand" | |
"net/http" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
execute pathogen#infect() | |
syntax on | |
set expandtab | |
set number | |
set ruler | |
set tabstop=4 | |
filetype plugin indent on | |
set statusline+=%#warningmsg# | |
set statusline+=%{SyntasticStatuslineFlag()} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get update | |
apt-get install -y software-properties-common | |
echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections | |
echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections | |
add-apt-repository -y ppa:webupd8team/java | |
dpkg --add-architecture i386 | |
apt-get update | |
apt-get install -y --force-yes apt-utils build-essential git unzip oracle-java8-installer python libreadline-dev curl bzip2 libssl-dev zlib1g-dev libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386 | |
apt-get -fy install | |
git clone https://github.com/rbenv/rbenv.git $HOME/.rbenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import okhttp3.*; | |
import okio.Buffer; | |
import javax.net.ssl.*; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.security.GeneralSecurityException; | |
import java.security.KeyStore; | |
import java.security.cert.Certificate; | |
import java.security.cert.CertificateFactory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.location.Address; | |
import android.location.Geocoder; | |
import java.io.IOException; | |
import rx.Observable; | |
import rx.Subscriber; | |
import rx.android.schedulers.AndroidSchedulers; | |
import rx.schedulers.Schedulers; |
NewerOlder