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
#ifndef MAXSIZE_HPP_ | |
#define MAXSIZE_HPP_ | |
#include <algorithm> | |
#include <cstddef> | |
template<class ... Ts> | |
struct Max { | |
static_assert(sizeof...(Ts) == 0, "This is the terminal case of the recursion, this assertion shall never fail"); | |
static constexpr std::size_t value = 0; |
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 <optional> | |
class Image | |
{ | |
public: | |
Image(const std::string& path) : path(path) | |
{} | |
std::string getPath() |
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
import re | |
import sys | |
def text_contains(text, *patterns): | |
""" Check if 'text' contains at least one of the strings given in 'patterns'.""" | |
for p in patterns: | |
if re.search(p, text, re.IGNORECASE): | |
# One pattern was found so the text contains at least of them | |
# So it is true that "it contains" |
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
from datetime import datetime | |
from datetime import date | |
birth = datetime.strptime("08-08-1987", "%d-%m-%Y").date() | |
today = date.today() | |
if birth.day == today.day and birth.month == today.month: | |
age = today.year - birth.year | |
print("It's your birthday! You're", age,"! : )") | |
print("Let's celebrate!") |
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
#ifndef LEDPANEL_HPP | |
#define LEDPANEL_HPP | |
#include <QWidget> | |
#include <cassert> | |
#include <QPainter> | |
class LedPanel : public QWidget | |
{ |
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> | |
using namespace std; | |
class FilePath | |
{ | |
public: | |
explicit FilePath(string filename) : | |
filename_m(filename), |
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 <chrono> | |
#include <iostream> | |
#include <thread> // to get sleep_for() | |
/** | |
* How to measure elapsed time in C++11. | |
* | |
* It uses 'steady_clock' because it is monotonic. Being monotonic means that it cannot decrease so it is the most suitable clock | |
* for time measurements. |
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
import functools | |
import operator | |
points = [100, 66, 33, 0] | |
weights = [-50, 0, 0, 0] | |
numerator = functools.reduce(operator.add, [p * w for p, w in zip(points, weights)], 0) | |
denomimator = functools.reduce(operator.add, weights, 0) | |
barycenter = numerator / denomimator |
NewerOlder