Skip to content

Instantly share code, notes, and snippets.

@jacobmoncur
jacobmoncur / index.html
Created July 26, 2012 04:26
A web page created at CodePen.io.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Tiles &middot; CodePen</title>
<!--
Copyright (c) 2012 jacobmoncur, http://codepen.io/jacobmoncur
Permission is hereby granted, free of charge, to any person obtaining
@jacobmoncur
jacobmoncur / gist:8587185
Created January 23, 2014 21:28
Gradle file for getting maven dependencies hosted on private github repo
repositories {
mavenCentral()
maven {
url = 'https://github.com/github-username/github-project/raw/master'
credentials {
username 'my-username'
password 'my-password'
}
}
}
@jacobmoncur
jacobmoncur / siri-speaks-gif
Created May 21, 2015 03:21
How to say GIF (according to siri)
let string = "This is how you say GIF."
let utterance = AVSpeechUtterance(string: string)
utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
utterance.rate = 0.15
utterance.pitchMultiplier = 1.2
utterance.preUtteranceDelay = 0.2
utterance.postUtteranceDelay = 0.2
let synthesizer = AVSpeechSynthesizer()
synthesizer.speakUtterance(utterance)
self.tableView.beginUpdates()
self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation:.Fade)
self.tableView.endUpdates()
@jacobmoncur
jacobmoncur / build.gradle
Created July 30, 2015 06:52
Kotlin + Junit build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.****.*****"
minSdkVersion 16
@jacobmoncur
jacobmoncur / AuthenticationTest.kt
Created July 30, 2015 06:54
Kotlin + Junit test class
import org.junit.Assert
import org.junit.Test as test
public class AuthenticationTest {
test public fun login() {
Assert.assertTrue(1 == 1)
}

Lambdas

button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        doSomethingAmazing();
    }
});
val snapshot = try {
cache[key] ?: return null
} catch (e: IOException) {
// Give up because the cache cannot be read.
return null
}

Extension Functions

Animator anim = ObjectAnimator.ofFloat(mainView, "translationY", 500.f);
anim.setInterpolator(new AccelerateDecelerateInterpolator());
anim.setDuration(300);
anim.setStartDelay(100);

Animator anim1 = ObjectAnimator.ofFloat(otherView, "translationY", 200.f);
anim1.setInterpolator(new AccelerateDecelerateInterpolator());

When

when(currentButtonState){
    ButtonState.GONE -> setupGoneButton(duration)
    ButtonState.BEGIN -> setupStartButton(duration)
    ButtonState.PROGRESS -> setupProgress()
    ButtonState.SUCCESS -> setupSuccessButton()
}