Skip to content

Instantly share code, notes, and snippets.

View kantoniak's full-sized avatar

Krzysztof (Chris) Antoniak kantoniak

View GitHub Profile
@kantoniak
kantoniak / FigureExtParsedown.class.php
Last active November 26, 2021 09:22
Parsedown extension to wrap single-image lines in <figure>, not <p>. Public domain. See https://github.com/erusev/parsedown/issues/180#issuecomment-451486639
<?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';
#include <gtest/gtest.h>
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
#include <string>
#include <gtest/gtest.h>
TEST(ExampleTest, First) {
EXPECT_EQ(std::string("Example"), std::string("Example"));
}
#include <algorithm>
#include <vector>
#include <gtest/gtest.h>
class ExampleClass : public testing::Test {
protected:
virtual void SetUp() {
numbers.push_back(1);
numbers.push_back(2);
#include <string>
#include <iostream>
#include "optional.hpp"
int main() {
std::optional<std::string> empty;
std::cout << empty.value_or("no value") << std::endl;
}
#ifndef OPTIONAL
#define OPTIONAL
#if __has_include(<optional>)
# include <optional>
#else
# include <experimental/optional>
namespace std {
template<typename T>
using optional = std::experimental::optional<T>;
<?php
namespace kantoniak {
class AboutMe {
// ...
public function __construct() {
<?php
class MyNewWidget extends WP_Widget {
function __construct() {
// Instantiate the parent object
parent::__construct('mynewwidgetbaseid, 'My New Widget Title');
}
function widget($args, $instance) {
@kantoniak
kantoniak / chrono-unixtimestamp.cpp
Created April 13, 2017 12:04
std::chrono example - getting unix timestamp
#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
kantoniak / chrono-gameloop.cpp
Last active December 12, 2020 22:24
std::chrono example - simple game loop
#include <chrono>
#include <iostream>
using namespace std::literals::chrono_literals;
void input() {
}
void update() {
// Do something to kill the time