Skip to content

Instantly share code, notes, and snippets.

@Rogach
Rogach / test.gradle
Last active February 2, 2023 15:18
searching for java8-openjfx build issue
ext.javaBinary = "/usr/lib/jvm/java-8-openjdk/bin/java"
def inStream = new java.io.BufferedReader(new java.io.InputStreamReader(new java.lang.ProcessBuilder(ext.javaBinary, "-version").start().getErrorStream()));
try {
String line = inStream.readLine();
while (line != null) {
if (line.contains("Runtime Environment (build ")) {
int ib = line.indexOf(" (build ");
if (ib != -1) {
String ver = line.substring(ib + 8, line.size() - 1);
project.ext.set("jdkRuntimeVersion", ver);
@Rogach
Rogach / input.tsv
Created March 1, 2021 11:36
issue when copying contents of a file into a variable
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
TTTфTфTффффTTTффTфффффTTTTфTTTффTTфTTфTTTфTффффT
ффTфTTTTTTфTTTTффффTTTфTффTTфффTфTTTфTфффTTTTTTT
фффTфTTTфффTфTфффффTффTффTTTфффTTфTффффTTTфффTфф
TTTфффTTффTфTфффTфффффффTTффTTфTфффTTффффTTфTффT
ффTTфTTфTфTTTфTфффффффффTфTTTффTфTTTTTфTTTTTTфTT
фффTфTффTфффTTTTффTTTфффTффTфTффTффTфTффTTфTTTфф
ффTфTфTTTTффTфTфффTTфффTфTфффTTTTффTTTTфTффTфффT
import sys
import math
range_min = int(sys.argv[1])
range_max = int(sys.argv[2])
def calculate_square_depth(range_min, range_max):
if range_max <= 3:
return 0
min_bound = math.ceil(range_min**0.5)
public class GetProperties {
public static void main(String[] args) {
System.out.println(System.getProperties());
}
}
;; input is from https://adventofcode.com/2015/day/6
(def W 1000)
(def input (clojure.string/split-lines (slurp "d06.txt")))
(defmacro control-lights [lights x1 y1 x2 y2 f]
(let [i (gensym)]
`(doseq [ x# (range ~x1 (inc ~x2))
y# (range ~y1 (inc ~y2))
:let [ ~i (+ (* y# W) x#) ] ]
(def W 1000)
(def input (clojure.string/split-lines (slurp "d06.txt")))
(let [lights (boolean-array (* W W))]
(doseq [s input]
(let [ m (re-matches #"(turn on|turn off|toggle) (\d+),(\d+) through (\d+),(\d+)" s)
command (get m 1)
x1 (Integer/parseInt (get m 2))
y1 (Integer/parseInt (get m 3))
x2 (Integer/parseInt (get m 4))
y2 (Integer/parseInt (get m 5)) ]
@Rogach
Rogach / Test.scala
Last active October 5, 2018 12:27
scallop #137 bug
import org.rogach.scallop._
import java.io.{Serializable, ByteArrayOutputStream, ByteArrayInputStream, ObjectOutputStream, ObjectInputStream}
trait PropsArgument extends ScallopConf {
@transient val p: Map[String, String] = props[String]('D')
}
class TestConf(args: List[String]) extends ScallopConf(args) with Serialization with PropsArgument {
val apples = opt[Int]("apples")
verify()
Alad commented on 2018-03-28 20:11
Thanks :)
runical commented on 2018-03-27 07:39
I'll probably have some time tomorrow evening. If that isn't a problem,
I'll be happy to apply the patches.
E: Currently updating and testing
@Rogach
Rogach / Test.scala
Created May 25, 2018 03:14
scallop-bug-161 test code
object Test {
def main(args: Array[String]) {
val conf = new TestClass(args)
}
}
import org.rogach.scallop.{ScallopConf, ScallopOption, Serialization, ValueConverter, singleArgConverter}
class TestClass(args: Seq[String]) extends ScallopConf(args) with Serialization {
import org.rogach.scallop._
import java.io.{Serializable, ByteArrayOutputStream, ByteArrayInputStream, ObjectOutputStream, ObjectInputStream}
val args = Array("--apples", "33")
private class ConfSerializationProxy(@transient private var orig: Conf) extends Serializable {
private def writeObject(out: ObjectOutputStream) {
out.defaultWriteObject()
out.writeObject(orig.args.toArray)
}