This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local.file_match "system" { | |
path_targets = [{ | |
__address__ = "localhost", | |
__path__ = "/var/log/*log", | |
job = "varlogs", | |
stream = "stdout", | |
}] | |
} | |
loki.source.file "system" { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Prometheus Node Exporter | |
Documentation=https://prometheus.io/docs/introduction/overview/ | |
Wants=network-online.target | |
After=network-online.target | |
[Service] | |
Type=simple | |
User=prometheus | |
Group=prometheus |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Prometheus | |
Documentation=https://prometheus.io/docs/introduction/overview/ | |
Wants=network-online.target | |
After=network-online.target | |
[Service] | |
Type=simple | |
User=prometheus | |
Group=prometheus |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool isPalindrome(int x) { | |
int originalNumber = x; | |
if (x < 0) { | |
return false; | |
} | |
// Reverse x | |
bool firstDigit = true; | |
int reversedNumber = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
By starting from the number 1 and repeatedly either adding 5 or multiplying | |
by 3, an infinite set of numbers can be produced. Write a function that, | |
given a number, tries to find a sequence of such additions and multiplications | |
that produces that number. | |
*/ | |
function findSolution(target) { | |
function find(current, history) { | |
console.log("==> " + history); | |
if (current == target) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let size = 100; | |
let result = ''; | |
for (let i = 1; i <= size; ++i) { | |
for (let j = 1; j <= size; ++j) { | |
if (i % 2 != 0) { | |
// odd row | |
if (j == 1) { | |
// first col | |
result += '_'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (let i = 1; i <= 100; ++i) { | |
if (i % 3 == 0 && i % 5 == 0) { | |
console.log("FizzBuzz"); | |
} else if (i % 3 == 0) { | |
console.log("Fizz"); | |
} else if (i % 5 == 0) { | |
console.log("Buzz"); | |
} else { | |
console.log(i); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (let i = 1; i <= 7; ++i) { | |
let ch = "#"; | |
for (let j = 1; j < i; ++j) { | |
ch = ch.concat("#"); | |
} | |
console.log(ch); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void printSquareStar(int number) { | |
if (number < 5) { | |
System.out.println("Invalid Value"); | |
return; | |
} | |
for (int i = 1; i <= number; i++) { | |
for (int j = 1; j <= number; j++) { | |
if (i == 1 || i == number) { | |
System.out.print("*"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Calculate the prime factor of a given number. | |
public static int getLargestPrime(int number) { | |
int largestPrime = -1; | |
if (number == 0 || number == 1 || number < 0) { | |
return -1; | |
} | |
if (number == 2 || number == 3) { | |
return number; |
NewerOlder