Skip to content

Instantly share code, notes, and snippets.

@Nikolayill
Nikolayill / PackageDependencyInspector.java
Created May 25, 2025 14:58
"Script" scans the project from the root package
package com.github.nikolayill;
import java.io.IOException;
import java.nio.file.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
/**
* https://kotlinlang.org/docs/delegated-properties.html
* https://stackoverflow.com/questions/49969998/kotlin-delegated-property-by-map-throwing-nosuchelementexception-if-not-present
*
*/
class MappingTest {
@Nikolayill
Nikolayill / getclip.java
Last active May 22, 2023 18:50
Java "script" that save a clipboard text content to file, or print it to console (on Win10 + Java 17)
import java.awt.datatransfer.*;
import java.awt.*;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
/**
* Java "script" that save a clipboard text content to file, or print it to console (cmd have some UTF8 issues by default)
* Usage java getclip.java <FILE_NAME>
@Service
@Primary
@RefreshScope
public class SwitchingServiceSwitchImpl implements SwitchingService {
private final SwitchingService serviceV1;
private final SwitchingService serviceV2;
private volatile SwitchingService active;
public SwitchingServiceSwitchImpl(SwitchingServiceImpl serviceV1, SwitchingServiceImplV2 serviceV2) {
this.serviceV1 = serviceV1;
fun <A, T, R> getStatefulMapperEx(acc: () -> A, map: (A,T) -> Pair<A,R>): (T) -> R {
var state = acc()
return { v:T ->
val (newState, result) = map(state, v)
state = newState
result
}
}
//Modified takeWhile to include a last value (that gives a false predicate result)
public fun <T> Sequence<T>.takeWhileInclusive(predicate: (T) -> Boolean): Sequence<T> {
return TakeWhileInclusiveSequence(this, predicate)
}
class TakeWhileInclusiveSequence<T>
constructor(
private val sequence: Sequence<T>,
private val predicate: (T) -> Boolean

※ Raspberry Pi RAID NAS Server Setup ※

Hardware:

  • Raspberry Pi 4 (4GB RAM)
  • Micro SD card 32GB
  • 2x Integral USB 3.1 flash drives 128GB

OS:

  • Raspbian Buster
@Nikolayill
Nikolayill / google-docs-copy.js
Created December 12, 2022 23:10 — forked from Snarp/google-docs-copy.js
Script to allow copying from a protected Google Doc
/*
<https://stackoverflow.com/questions/40296831/is-it-possible-to-force-a-copy-of-a-protected-google-doc>
NOTE - 2021-05-24
-----------------
The script below isn't the fastest way to copy-and-paste from a protected
Google Doc. Before trying it, I'd suggest following MikoFrosty's advice from
the comments:
@Nikolayill
Nikolayill / fangxiao-domains-pihole-blocklist-11-2022
Created November 20, 2022 08:05 — forked from leviem1/fangxiao-domains-pihole-blocklist-11-2022
PiHole blocklist for phishing domains used by Fangxiao: bleepingcomputer.com/news/security/42-000-sites-used-to-trap-users-in-brand-impersonation-scheme/
This file has been truncated, but you can view the full file.
0.0.0.0 002sen.cn
0.0.0.0 003bty.cyou
0.0.0.0 005nj7z.cn
0.0.0.0 006ks4g.cn
0.0.0.0 0072875.xyz
0.0.0.0 0099q7e.cn
0.0.0.0 009gfy.cyou
0.0.0.0 00ckpr.cn
0.0.0.0 00cojpj.cn
0.0.0.0 00cvl.cn

Configure the Raspberry Pi

Install Raspbian Lite

  • Download Raspbian Lite
  • Download and install balenaEtcher
  • Flash the Raspbian Lite .img or .zip to an SD card using balenaEtcher

Optimize & configure the Raspberry Pi

  • Turn on the Raspberry Pi and wait for it to boot to the CLI
  • Enter sudo raspi-config
    • Select 1 Change User Password and create a unique password
  • Optional: Select 2 Network Options > N1 Hostname