This file contains hidden or 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 x.y | |
fun main(args: Array<String>) { | |
loops() | |
stringAndArrays() | |
arrays() | |
} |
This file contains hidden or 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 x.y | |
import java.util.* | |
import kotlin.math.log2 | |
fun main() { | |
val array: Array<Int?> = arrayOf(6, 7, 8, 2, 7, 1, 3, 9, null, 1, 4, null, null, null, 5) | |
val root = insertLevelOrder(array, 0) | |
val depth = log2(array.size.toDouble()).toInt() |
This file contains hidden or 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 io.reactivex.Completable | |
import io.reactivex.schedulers.Schedulers | |
import timber.log.Timber | |
import java.io.BufferedWriter | |
import java.io.File | |
import java.io.FileWriter | |
import java.io.IOException | |
object TextFileLogger { |
This file contains hidden or 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 main() { | |
println() | |
val base = 25000 // Monthly pay | |
val growth0 = arrayOf(0f, 0.05f, 0.05f, 0.05f, 0.05f) // Growth rate | |
val durations0 = arrayOf(12, 12, 12, 12, 12) // Months | |
print(base, growth0, durations0, "5 Years") |
This file contains hidden or 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
// Find the Levenshtein distance | |
private int distance(String a, String b) { | |
a = a.toLowerCase(); | |
b = b.toLowerCase(); | |
int[] costs = new int[b.length() + 1]; | |
for (int j = 0; j < costs.length; j++) | |
costs[j] = j; | |
for (int i = 1; i <= a.length(); i++) { | |
costs[0] = i; |
This file contains hidden or 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.util.Collection; | |
import java.util.Iterator; | |
import java.util.concurrent.LinkedTransferQueue; | |
import java.util.concurrent.ThreadPoolExecutor; | |
import java.util.concurrent.TimeUnit; | |
import java.util.concurrent.TransferQueue; | |
import java.util.concurrent.locks.ReentrantLock; | |
public final class ScalableThreadPoolExecutor extends ThreadPoolExecutor { |
This file contains hidden or 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.util.Date; | |
import java.util.Locale; | |
import java.util.TimeZone; | |
import java.text.SimpleDateFormat; | |
import java.text.DateFormat; | |
public class DateFormatterDemo { | |
public static void main(String[] args) throws Exception { | |
This file contains hidden or 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 static int blendColors(int color1, int color2, float ratio) { | |
final float inverseRation = 1f - ratio; | |
float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation); | |
float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation); | |
float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation); | |
return Color.rgb((int) r, (int) g, (int) b); | |
} |
This file contains hidden or 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.graphics.Canvas; | |
import android.graphics.Color; | |
import android.graphics.ColorFilter; | |
import android.graphics.Paint; | |
import android.graphics.Rect; | |
import android.graphics.RectF; | |
import android.graphics.drawable.Drawable; | |
import android.util.DisplayMetrics; | |
/** |
This file contains hidden or 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
//In src folder | |
public class HelloWorld { | |
public static void main(String[] args) { | |
System.out.println("Hello World!"); | |
} | |
} |
NewerOlder