Skip to content

Instantly share code, notes, and snippets.


Krzysztof Antoniak kantoniak

View GitHub Profile
kantoniak / FigureExtParsedown.class.php
Last active Dec 24, 2020
Parsedown extension to wrap single-image lines in <figure>, not <p>. Public domain. See
View FigureExtParsedown.class.php
class FigureExtParsedown extends Parsedown {
// Matches Markdown image definition
private $MarkdownImageRegex = "~^!\[.*?\]\(.*?\)$~";
public function __construct () {
// Add blockFigure to non-exclusive handlers for text starting with !
$this->BlockTypes['!'][] = 'Figure';
View main.cpp
#include <gtest/gtest.h>
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
View test-example.cpp
#include <string>
#include <gtest/gtest.h>
TEST(ExampleTest, First) {
EXPECT_EQ(std::string("Example"), std::string("Example"));
View test-exampleclass.cpp
#include <algorithm>
#include <vector>
#include <gtest/gtest.h>
class ExampleClass : public testing::Test {
virtual void SetUp() {
View main.cpp
#include <string>
#include <iostream>
#include "optional.hpp"
int main() {
std::optional<std::string> empty;
std::cout << empty.value_or("no value") << std::endl;
View optional.hpp
#ifndef OPTIONAL
#define OPTIONAL
#if __has_include(<optional>)
# include <optional>
# include <experimental/optional>
namespace std {
template<typename T>
using optional = std::experimental::optional<T>;
View wp-widget-connector-example.php
namespace kantoniak {
class AboutMe {
// ...
public function __construct() {
View wp-widget-example.php
class MyNewWidget extends WP_Widget {
function __construct() {
// Instantiate the parent object
parent::__construct('mynewwidgetbaseid, 'My New Widget Title');
function widget($args, $instance) {
kantoniak / chrono-unixtimestamp.cpp
Created Apr 13, 2017
std::chrono example - getting unix timestamp
View chrono-unixtimestamp.cpp
#include <chrono>
#include <ctime>
#include <iostream>
int main() {
// std::chrono only
auto now = std::chrono::system_clock::now();
std::cout << "std::chrono only: " << std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count() << std::endl;
kantoniak / chrono-gameloop.cpp
Last active Dec 12, 2020
std::chrono example - simple game loop
View chrono-gameloop.cpp
#include <chrono>
#include <iostream>
using namespace std::literals::chrono_literals;
void input() {
void update() {
// Do something to kill the time