This file contains 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 <iostream> | |
#include <string> | |
/** | |
* Optimized aggregating strings | |
* used Args pack | |
*/ | |
template <unsigned short size> | |
struct StrJoinInitializer | |
{ |
This file contains 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
#!/bin/sh | |
# | |
# | |
# Script to auto mount external device | |
# If for some reason you do not want to use the fstab file, this script will be a resolve | |
# | |
This file contains 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
join :: Char -> [String] -> String | |
join _ [] = [] | |
join _ [s] = s | |
join gl arr = | |
head arr ++ gl : joingl (tail arr) | |
where | |
joingl = join gl | |
putStrLn (join ':' ["str1", "str2", "str3"]) |
This file contains 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
/** | |
* This is a helper class. | |
* It can be used only inside the function ListInitializer tolist(Args&& ...args) | |
* ListInitializer list(Args&& ...args) | |
* In all other cases, use it not possible | |
* size is the number of arguments with which the constructor was called | |
*/ | |
template<typename DataType, unsigned size> | |
class ListInitializer | |
{ |
This file contains 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 <vector> | |
#include <iostream> | |
class A | |
{ | |
private: | |
struct private_key {}; | |
// private constructor | |
A(int a) : | |
a(a) |
This file contains 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
module StringManip; | |
import std.range : empty, popFront, front; | |
auto destr(Arg0, Args...)(ref Arg0 arg0, ref Args args) | |
{ | |
return DestrInstance!(Arg0, Args.length+1)(arg0, args); | |
} |
This file contains 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
// | |
// CRTP. Double static polymorphism | |
// | |
// g++ -std=c++14 1.cpp && ./a.out | |
#include <iostream> | |
#include <string> | |
using std::cout; |
This file contains 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
#!/bin/bash | |
for tz in $(timedatectl list-timezones | grep -v 'UTC') | |
do | |
gmtoff=$(zdump -v "$tz" | grep 'gmtoff' | tail -n1 | grep -oE "[^ ]+$") | |
tz_offset="${gmtoff:7}" | |
if [[ "${gmtoff:0:7}" == "gmtoff=" ]]; then | |
echo "$tz;$tz_offset" | |
fi |
This file contains 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
// | |
// May destructing variables for itarable types and tuples | |
// | |
module vlm.utils.destructing; | |
import std.range : empty, popFront, front; | |
import std.traits : isIterable; | |
import std.typecons : Tuple, tuple, isTuple; | |
import std.functional : forward; |
This file contains 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
// if constexpr to switch type | |
// | |
template<uint8_t N> | |
struct _buf_type | |
{ | |
static_assert(N > 0, "Buffer must be more then 0"); | |
static_assert(N <= 64, "Maximum buffer size is 64"); | |
constexpr static auto _i2t() | |
{ | |
if constexpr (N <= 8 ) {return uint8_t(0) ;} |
OlderNewer