K

@koldev

Java DN test

Java
1 month ago
import java.util.*; import java.lang.*; import java.io.*; // The main method must be in a class named "Main". class Main { public static void main(String[] args) { test_getBaseDns(); test_isDescendantOf(); test_isAncestorOf();

Remove empty lines from string

C#
3 months ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { var ss = new[] { "", "line", "line1\nline2",

Parse ping output

C#
4 months ago
using System; using System.Diagnostics; using System.Text.RegularExpressions; namespace PingOutputParserTest { public class PingResult { public double Delay { get; } public double Jitter { get; } public double Loss { get; }

Playing with NodeJS

NodeJS
6 months ago
class Point { x; y; } class Point2 { #x; #y; constructor(x, y) {

Playing with C++

C++
6 months ago
#include <iostream> #include <string> #include <sstream> #include <vector> using namespace std; struct Point { int x; int y;

C pointers

C
6 months ago
#include <stdio.h> int main() { char c = 'A'; char* pc = &c; printf("pc = %lld\n", (long long) pc); printf("pc + 1 = %lld\n", (long long) (pc + 1)); int i = 42; int* pi = &i;

Java: variable number of arguments

Java
7 months ago
import java.util.*; import java.lang.*; import java.io.*; // The main method must be in a class named "Main". class Main { public static void main(String[] args) { f(); f(new String[0]); f(new String[1]);

Test: removeAttributesFromPath

Java
7 months ago
import java.util.*; import java.lang.*; import java.io.*; // The main method must be in a class named "Main". class Main { public static void main(String[] args) { String[] paths = new String[] { "", "myElement",

Java: Get type parameter

Java
8 months ago
import java.util.*; import java.lang.*; import java.io.*; import java.lang.reflect.*; import java.net.*; // The main method must be in a class named "Main". class Main { public static void main(String[] args) throws Exception { TypeReference<X> ref = new TypeReference<X>() {};

Keep only the latest version

Python
1 year ago
import pprint import re VERSION_PATTERN = r"\d+\.\d+" def version_to_int(version: str) -> int: i = version.index(".") major_version = int(version[:i])

Varargs size

Java
1 year ago
import java.util.*; import java.lang.*; import java.io.*; // The main method must be in a class named "Main". class Main { public static void main(String[] args) { f(null); f((String[]) null);

List comparison

Java
2 years ago
import java.util.*; import java.lang.*; import java.io.*; // The main method must be in a class named "Main". class Main { public static void main(String[] args) { List<String> list1 = Arrays.asList(new String[] {"aaa", "bbb", "ccc"}); List<String> list2 = Arrays.asList(new String[] {"aaa", "bbb", "ccc"}); List<String> list3 = Arrays.asList(new String[] {"aaa", "ccc", "bbb"});

Boolean as boolean

Java
2 years ago
import java.util.*; import java.lang.*; import java.io.*; class Main { public static void main(String[] args) { f(null); f(false); f(true); }

Vill

Python
2 years ago
k = 1 for i in range(1, 11): a = [] for j in range(1, i + 1): a.append(k) k = k + 2 print(a, sum(a))

SQL Server - INNER JOIN WITH DISTINCT

SQL
2 years ago
create table AddTbl ( FirstName TEXT, LastName TEXT, Birth INTEGER ); create table ValTbl ( LastName TEXT, District TEXT );

Nullable in Java?

Java
2 years ago
import java.util.*; import java.lang.*; import java.io.*; // The main method must be in a class named "Main". class Main { public static void main(String[] args) { var l = new long[] { 1L, 2L, 3L }; for (var b : new boolean[] { true, false }) { var a = b ? (Long)l[0] : null;

Nullable vs. boxed

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { var l = new[] { 1L, 2L, 3L }; foreach (var b in new[] { true, false}) { var a = b ? l[0] : (long?)null; var o = b ? l[0] : (object)null; Console.WriteLine($"{b}, {(a is long)}, {a.HasValue}, '{a}'");

ConcurrentModificationException: At least 2 items are needed

Java
2 years ago
import java.util.*; import java.util.concurrent.*; import java.lang.*; import java.io.*; // The main method must be in a class named "Main". class Main { public static void main(String[] args) { //var map = new HashMap<Long, Object>(); // throws ConcurrentModificationException //var map = Collections.synchronizedMap(new HashMap<Long, Object>()); // throws ConcurrentModificationException

Truncation behavior of `snprintf`

C
2 years ago
#include <stdio.h> /* Output (after the warnings): buf: '0123', ret1: 4 buf: '0123456', ret2: 8 buf: '0123456', ret3: 9 buf: '0123456', ret4: 12 */ int main() {

Printing an exception

Java
2 years ago
import java.util.*; import java.util.stream.*; import java.lang.*; import java.io.*; import java.text.*; // The main method must be in a class named "Main". class Main { public static void main(String[] args) { try {