Skip to content

Instantly share code, notes, and snippets.

@Smail
Smail / string_split.cpp
Created March 9, 2024 02:40
C++ String Split
constexpr std::vector<std::string> split(const std::string& str, std::string_view delimiter = " ") {
std::vector<std::string> xs{};
int start = 0;
int end = 0;
int delimiter_index = 0;
for (; end < str.size(); ++end) {
if (str[end] != delimiter[delimiter_index]) [[likely]] {
end -= delimiter_index;
delimiter_index = 0;
BasedOnStyle: Google
DerivePointerAlignment: false
IndentWidth: 4
AccessModifierOffset: -2
ColumnLimit: 100
AllowShortCaseLabelsOnASingleLine: true
InsertBraces: true
LineEnding: LF
@Smail
Smail / Change-Java-Home.ps1
Created May 16, 2020 00:10
Change Java Home via PowerShell, Scoop and OpenJDK
# You need to add %JAVA_HOME%bin to the beginning of your Path variable
$version = $args[0].trim()
$helpText = "To change to the latest OpenJDK version enter 'latest', otherwise enter the version you want to use." + [Environment]::NewLine + "Usage: Change-Java-JDK (latest|\d|-{0,2}help)"
if ($version -eq "latest") {
$version = ""
} elseif ($version -match "^\s*-{0,2}help\s*$") {
Write-Host $helpText
return
} elseif (!($version -match "^\d+$")) {