Skip to content

Instantly share code, notes, and snippets.

View Vest's full-sized avatar
💥
Saving the world!

Vest Vest

💥
Saving the world!
View GitHub Profile
@Vest
Vest / MontyHall.html
Created October 30, 2020 16:04
MontyHall demo, stupid code from my past. Open it with: https://gistpreview.github.io/?1bf86c579ae4b3b5320e976d8f6ec959
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>MontyHall Paradox</title>
<meta charset="UTF-8">
@Vest
Vest / indexOfAny.rs
Last active July 17, 2020 11:41
A strange Gist to find indices / indexes of chars in the &str using Rust
fn index_of_any(str: &str, search_chars: &[char]) -> Vec<usize> {
str.char_indices()
.filter(|ci| search_chars.contains(&ci.1))
.map(|ci| ci.0)
.collect()
}
fn main() {
let str = "abccd";
@Vest
Vest / indexOfAny.java
Last active July 17, 2020 11:39
A strange Gist to find indices / indexes of chars in the String using streams, no "for" loops.
import java.util.Arrays;
import java.util.stream.IntStream;
public class Main {
public static int[] indexOfAny(String str, char[] searchChars) {
return IntStream.range(0, str.length())
.filter(i -> IntStream.range(0, searchChars.length)
.anyMatch(ci -> searchChars[ci] == str.charAt(i)))
.toArray();
@Vest
Vest / Fritzbox VPN Access Home.mobileconfig
Created July 1, 2020 10:00
Example iOS VPN On-Demand Rules for FRITZ!Box
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<!---
Source:
https://developer.apple.com/business/documentation/Configuration-Profile-Reference.pdf
https://www.derman.com/blogs/Example-iOS-VPN-OnDemand-Rules
-->
<dict>
<key>PayloadContent</key>
@Vest
Vest / JMH - Path vs File performance
Last active December 17, 2019 15:09
JHM test and results - difference between Path.toFile().exists(), Files.isRegularFile(Path) and Files.exists(Path) for cases whether the file exists or not (Windows)
C:\jdk\build\windows-x86_64-server-release\images\jdk\bin\java.exe -javaagent:C:\Progs\idea-2019.3\lib\idea_rt.jar=49476:C:\Progs\idea-2019.3\bin -Dfile.encoding=UTF-8 -classpath C:\workspace\jmh_file_exists\target\classes;C:\Users\Vest\.m2\repository\org\openjdk\jmh\jmh-core\1.22\jmh-core-1.22.jar;C:\Users\Vest\.m2\repository\net\sf\jopt-simple\jopt-simple\4.6\jopt-simple-4.6.jar;C:\Users\Vest\.m2\repository\org\apache\commons\commons-math3\3.2\commons-math3-3.2.jar org.sample.MyBenchmark
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.openjdk.jmh.util.Utils (file:/C:/Users/Vest/.m2/repository/org/openjdk/jmh/jmh-core/1.22/jmh-core-1.22.jar) to field java.io.PrintStream.charOut
WARNING: Please consider reporting this to the maintainers of org.openjdk.jmh.util.Utils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
# JMH version: 1