Skip to content

Instantly share code, notes, and snippets.

@sagi-z
sagi-z / featured-image--jekyll-post-snippets.html
Created September 21, 2019 11:47 — forked from pmacMaps/featured-image--jekyll-post-snippets.html
Sample code for Jekyll Featured Image Template Blog Post
<!-- 1. Post File [2018-09-30-Sample-Post.md] -->
---
layout: post
title: A Sample Post
date: 2018-09-30
author: Mike the Blogger
description: This is the one blog post to rule them all
featured-image: my-awesome-photo.jpg
featured-image-alt: Mike the Blogger speaking at Times Square, New York City, New York
categories: Side Hustle
#include <iostream>
#include <string>
#include "dispatcher.hpp" // the implementation is here
using namespace std;
// a dummy enum for this example
enum EventEnum {EVENT1, EVENT2, EVENT3};
int main(int argc, char *argv[])
#ifndef __DISPATCHER_H
#define __DISPATCHER_H
#include <functional>
#include <list>
template <typename... Args>
class Dispatcher
{
public:
@sagi-z
sagi-z / python_tests_dir_structure.md
Created September 13, 2017 10:21 — forked from tasdikrahman/python_tests_dir_structure.md
Typical Directory structure for python tests

A Typical directory structure for running tests using unittest

Ref : stackoverflow

The best solution in my opinion is to use the unittest [command line interface][1] which will add the directory to the sys.path so you don't have to (done in the TestLoader class).

For example for a directory structure like this:

new_project

├── antigravity.py

int main()
{
Mat image = Mat::zeros(768, 1024, CV_8UC3);
Canvas c("Counting People", image.size());
c.enableScreenText();
help(c);
c.enableStatusMsg();
class CountingManager
{
public:
CountingManager(Canvas &c)
{
c.notifyOnShapeCreate([&c, this](Shape* shape)
{ // User created a shape
if (shape->getType() == LineCrossing::type)
{ // Add the LineCrossing to out list
LineCrossing *pLineCrossing = (LineCrossing*) shape;
// TBB NOTE: This usage below is just for the tbb demonstration.
// It is not an example for good OO code. The lambda
// expressions are used to easily show the correleation
// between the original code and the tbb code.
void detectAndDrawTBB( VideoCapture &capture,
tbb::concurrent_bounded_queue<ProcessingChainData *> &guiQueue,
CascadeClassifier& cascade,
CascadeClassifier& nestedCascade,
double scale, bool tryflip )
{
//...
if( capture.isOpened() )
{
//...
tbb::concurrent_bounded_queue<ProcessingChainData *> guiQueue;
guiQueue.set_capacity(2); // TBB NOTE: flow control so the pipeline won't fill too much RAM
auto pipelineRunner = thread( detectAndDrawTBB, ref(capture), ref(guiQueue), ref(cascade), ref(nestedCascade), scale, tryflip );
//...
#include <thread>
#include <tbb/concurrent_queue.h>
#include <tbb/pipeline.h>
volatile bool done = false; // volatile is enough here. We don't need a mutex for this simple flag.
struct ProcessingChainData
{
Mat img;
vector<Rect> faces, faces2;
Mat gray, smallImg;
};
#!/bin/sh
if [ "$1" = "-h" ]; then
echo "Usage: $0 [filename]"
exit
fi
# Get the IP automatically - this will prompt for a password because of sudo usage
ip=`sudo arp-scan -localnet | perl -ne 'print $1 if /(\S+).*Rigol/i'`
if [ "$ip" = "" ]; then