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
interface IBill { | |
String getType(); | |
void execute(); //假設你要做野 | |
} | |
class ElectricityBill implements IBill { | |
int billDay; | |
int kw; | |
String region; |
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 fun swap(list: MutableList<T>) : (Int, Int) -> Unit { | |
return fun(pos1: Int, pos2: Int): Unit { | |
return { | |
tmp = list[pos1] | |
list[pos1] = list[pos2] | |
list[pos2] = tmp | |
}() | |
} | |
} |
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 final Function2 swap(final List list) { | |
return (Function2)(new Function2() { | |
// $FF: synthetic method | |
// $FF: bridge method | |
public Object invoke(Object var1, Object var2) { | |
this.invoke(((Number)var1).intValue(), ((Number)var2).intValue()); | |
return Unit.INSTANCE; | |
} | |
public final void invoke(final int pos1, final int pos2) { |
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
//FuckTokenStream | |
import java.io.*; | |
public class FuckTokenStream implements TokenStream { | |
private BufferedReader br; | |
private int pos = 0; | |
private char[] cache; | |
FuckTokenStream(InputStream is) { |
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
class CheckCal { | |
private val MAX = 128 | |
private val valStack = Stack<Int>(MAX) | |
private val opStack = Stack<Char>(MAX) | |
private var buf = CharArray(MAX) | |
fun startCheck(inStream: InputStream) { | |
val reader = inStream.bufferedReader() | |
var prev: Int? = null | |
loop@ while(reader.read(buf) != -1) { |
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
class BinarySearchTree<T : Comparable<T>>() { | |
private var root: BinaryNode<T>? = null | |
constructor(element: T) : this() { | |
root = BinaryNode(element) | |
} | |
fun getRoot() = root | |
fun insert(element: T) : Boolean { |
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: Comparable<T>> eWhen(target: T, tester: Tester<T>.() -> Unit) { | |
val test = Tester(target) | |
test.tester() | |
test.filterList.firstOrNull { it.filter }?.invoke() ?: return | |
} | |
class Tester<T: Comparable<T>>(val it: T) { | |
val filterList = mutableListOf<Filter>() |
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: Comparable<T>> eWhen(target: T, tester: Tester<T>.() -> Unit) { | |
val test = Tester(target) | |
test.tester() | |
test.funFiltered?.invoke() ?: return | |
} | |
class Tester<T: Comparable<T>>(val it: T) { | |
var funFiltered: (() -> Unit)? = null | |
infix fun Boolean.then(block: () -> Unit) { |
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 main(args: Array<String>) { | |
fib.take(10).forEach { println(it) } | |
} | |
val fib = buildSequence { | |
var tmp = Pair(0, 1) | |
while(true) { | |
yield(tmp.first) | |
tmp = Pair(tmp.second, tmp.first + tmp.second) | |
} |
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/bash | |
#check network connection | |
con=$(ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null && echo ok || echo error) | |
if [ $con == "error" ]; then | |
exit -1 | |
fi | |
timedatectl set-ntp true | |
lsblk |
OlderNewer