Skip to content

Instantly share code, notes, and snippets.

Krzysztof Antoniak kantoniak

View GitHub Profile
@kantoniak
kantoniak / FigureExtParsedown.class.php
Last active Feb 28, 2020
Parsedown extension to wrap single-image lines in <figure>, not <p>. Public domain. See https://github.com/erusev/parsedown/issues/180#issuecomment-451486639
View FigureExtParsedown.class.php
<?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 {
protected:
virtual void SetUp() {
numbers.push_back(1);
numbers.push_back(2);
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>
#else
# include <experimental/optional>
namespace std {
template<typename T>
using optional = std::experimental::optional<T>;
View wp-widget-connector-example.php
<?php
namespace kantoniak {
class AboutMe {
// ...
public function __construct() {
View wp-widget-example.php
<?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 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
kantoniak / chrono-gameloop.cpp
Last active Apr 13, 2017
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
You can’t perform that action at this time.