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 com.squareup.moshi.Json | |
import com.squareup.moshi.KotlinJsonAdapterFactory | |
import com.squareup.moshi.Moshi | |
import com.squareup.moshi.Rfc3339DateJsonAdapter | |
import java.util.Date | |
val json = """ | |
{ | |
"url": "https://api.github.com/repos/square/okio/issues/156", | |
"id": 91393390, |
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
/* | |
* Copyright (C) 2016 Square, Inc. | |
* | |
* 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 |
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
/* | |
* Copyright (C) 2014 Square, Inc. | |
* | |
* 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 |
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 java.math.BigInteger | |
interface Fibonacci { | |
fun fib(n: Int): Int | |
} | |
object LawfulGood : Fibonacci { | |
override fun fib(n: Int): Int { | |
check(n >= 0) { "fib is undefined for negative values: $n" } | |
return when (n) { |
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
\\ // | |
\\ .ooo. // | |
.@@@@@@@@@. | |
:@@@@@@@@@@@@@: | |
:@@. '@@@@@' .@@: | |
@@@@@@@@@@@@@@@@@ | |
@@@@@@@@@@@@@@@@@ | |
:@@ :@@@@@@@@@@@@@@@@@. @@: |
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
/* | |
* Copyright (C) 2021 Square, Inc. | |
* | |
* 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 |
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 java.io.IOException; | |
import okhttp3.Interceptor; | |
import okhttp3.Response; | |
import static okhttp3.internal.http.StatusLine.HTTP_PERM_REDIRECT; | |
import static okhttp3.internal.http.StatusLine.HTTP_TEMP_REDIRECT; | |
/** | |
* In OkHttp 4.5 and earlier, HTTP 307 and 308 redirects were only honored if the request method | |
* was GET or HEAD. |
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 okio.buffer | |
import okio.source | |
/** | |
* Converts a Kotlin file with `backtick method names` to camelCaseMethodNames. | |
*/ | |
fun main() { | |
val source = System.`in`.source().buffer() | |
while (true) { | |
val line = source.readUtf8Line() ?: break |
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
public final long readVarint64() throws IOException { | |
if (this.state != 0 && this.state != 2) { | |
throw (Throwable)(new ProtocolException("Expected VARINT or LENGTH_DELIMITED but was " + this.state)); | |
} else { | |
int shift = 0; | |
for(long result = 0L; shift < 64; shift += 7) { | |
this.source.require(1L); | |
int var10001 = this.pos++; | |
byte b = this.source.readByte(); |
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
/*bin/mkdir /tmp/rip 2> /dev/null | |
javac -d /tmp/rip $0 | |
java -cp /tmp/rip Rip "$@" | |
exit | |
*/ | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.util.*; | |
import java.util.regex.Matcher; |