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
#include <format> | |
#include <iostream> | |
using namespace std; | |
/** | |
* @brief inserts into the `src` string, every `group_len` characters, the `sep` string; depending on the | |
* `right_to_left` parameter starts counting characters from left (when =false) or from right (when =true) | |
* It does NOT change the original string passed as an argument | |
* @param src source string the separators are to be inserted into | |
* @param sep separators to be inserted into the `src` string | |
* @param group_len the `sep` string will be inserted into `src` string every `group_len` characters |
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
The `fsck` command (file system check) works as a kind of _wrapper_ for file-system-type-dependent specialized commands, | |
and the options allowed MAY VARY depending of the file system type... | |
For example: | |
- for `fat32` file system the `fsck.vfat` is used, and the `-c N` option selects the `DOS codepage`, | |
and the `-t` option tests for bad clusters | |
- for `ext4` file system the `e2fsck` is used, and checking for bad blocks requires the `-c` (read-only test) option | |
or the `-cc` (read/non-destructive-write test) option - and the `badblocks` command is used then under the hood | |
- some linux systems contain the `fsck.ntfs` command, but some don't. And it seems the `ntfsfix` command | |
doesn't offer the `bad blocks` check, and the `badblocks` command lists the bad bocks found, but apparently doesn't | |
update the `bad blocks list` of the device |
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
import pandas as pd | |
# suppose we have a simple 'stocks' dataframe: | |
stocks = pd.read_csv('http://bit.ly/smallstocks') | |
"""# stocks | |
Date Close Volume Symbol | |
0 2016-10-03 31.50 14070500 CSCO | |
1 2016-10-03 112.52 21701800 AAPL | |
2 2016-10-03 57.42 19189500 MSFT |
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
import kotlin.collections.ArrayDeque | |
// version #1 - the shortest implementation | |
// fun checkPalindrome(word: String): Boolean = word.reversed() == word | |
// version #2 - 'pure stack' implementation | |
/* | |
fun checkPalindrome(word: String): Boolean { | |
if (word.isBlank()) | |
return false |
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
// package some_kotlin_utils | |
/** | |
* handles the 'end of stream (EOF) case' - e.g. when the user presses "Ctrl-D" instead of typing a string; | |
* in this case returns the passed default value (e.g. "") instead of throwing an exception as 'plain' readln() does | |
* | |
* @param default String value returned when exception occurred | |
* @param printErrMsg Boolean when true prints the message connected with an exception to 'stderr' | |
* | |
* @return the user-entered string or the passed default value when an exception occurred |
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
import utils.XMLResourceBundle | |
import utils.XMLResourceBundleControl | |
import java.util.* | |
fun main() { | |
val resBndl1 = ResourceBundle.getBundle("props", Locale.forLanguageTag("pl"), XMLResourceBundleControl()) | |
println(resBndl1.getString("app_name") // prints: "Moja apka" | |
val resBndl2 = XMLResourceBundle.getBundle("props") // gets default Locale | |
println(resBndl2.getString("prop1") // prints: "Example 1" |
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
package test; | |
import java.io.FileNotFoundException; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.util.Properties; | |
import java.util.ResourceBundle; | |
public class TestClass { |
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
import java.util.Calendar; | |
import java.util.GregorianCalendar; | |
class GregorianCalendarPlayground1 { | |
public static void main(String[ ] args) { | |
Calendar gregCal = new GregorianCalendar(); | |
// wrong date, but the class in default 'lenient' mode should maintain this | |
gregCal.set(0, Calendar.DECEMBER, 31); |
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
to troubleshoot the log4j (ver1.*) it was enough to provide the: | |
-Dlog4j.debug | |
option to the JVM, e.g.: | |
java -Dlog4j.debug -jar test.jar | |
the equivilent option for log4j2 is: | |
-Dlog4j2.debug | |
or: | |
-Dorg.apache.logging.log4j.simplelog.StatusLogger.level=trace | |
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
```kotlin | |
const val HEX_LOWERCASE_DIGITS = "0123456789abcdef" | |
const val HEX_UPPERCASE_DIGITS = "0123456789ABCDEF" | |
const val HEX_DIGITS = "0123456789ABCDEFabcdef" | |
// ====================================================================================== | |
// ByteArray and UByteArray 'toChars' extension functions | |
// |
NewerOlder