Skip to content

Instantly share code, notes, and snippets.

View vladiant's full-sized avatar
🏠
Working from home

Vladislav Antonov vladiant

🏠
Working from home
View GitHub Profile
@vladiant
vladiant / cubePCA.ipynb
Last active October 31, 2020 22:27
3D points curve fitting
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vladiant
vladiant / example1.cpp
Created November 11, 2020 20:49
Overload operator << for C style arrays
#include <iostream>
#include <iomanip>
#include <sstream>
template<typename T, size_t N,
std::enable_if_t<!(std::is_same<T, char>::value||std::is_same<T, unsigned char>::value), bool> = true>
std::istream& operator>>(std::istream& in, T(&arr)[N]) {
for(auto& a: arr) {
in >> a;
}
@vladiant
vladiant / load_csv.cpp
Created December 5, 2020 23:24
C++ Opencv load CSV file as cv::Mat
CvMLData mlData;
mlData.read_csv("cameraFrame1.csv");
const CvMat* tmp = mlData.get_values();
cv::Mat img(tmp, true);
tmp->CvMat::~CvMat();
std::cout << "img: " << img << std::endl;
cv::namedWindow("img");
cv::imshow("img", img);
@vladiant
vladiant / read_csv_flatten_json.py
Last active December 6, 2020 00:46
Read csv and flatten json fields
# https://www.kaggle.com/julian3833/1-quick-start-read-csv-and-flatten-json-fields/execution
import os
import json
import numpy as np
import pandas as pd
from pandas.io.json import json_normalize
def load_df(csv_path='../input/train.csv', nrows=None):
JSON_COLUMNS = ['device', 'geoNetwork', 'totals', 'trafficSource']
@vladiant
vladiant / meta_polymoprhism_1.cpp
Last active December 18, 2020 14:53
Meta Polymorphism - Jonathan Boccara - Meeting C++ 2020 Opening Keynote
// Example program
#include <any>
#include <iostream>
#include <vector>
struct Interface {
virtual void draw() const = 0;
virtual ~Interface() = default;
};
@vladiant
vladiant / visit_example.cpp
Last active June 5, 2021 20:40
visit.example.cpp
// https://www.youtube.com/watch?v=KRUnZa9OBAM
// Generic Programming Without (Writing Your Own) Templates - Tina Ulbrich [ ACCU 2021 ]
#include <cmath>
#include <iostream>
#include <utility>
#include <variant>
using roots = std::variant<std::pair<double, double>, double, std::monostate>;
@vladiant
vladiant / exporting.h
Created June 5, 2021 20:10
Export methods
#pragma once
#ifdef _EXPORT
#ifdef _MSC_VER
#define DLL_API __declspec(dllexport)
#elif defined __GNUC__
#define DLL_API __attribute__((visibility("default")))
#endif
#else
#ifdef _MSC_VER
@vladiant
vladiant / concept.cpp
Last active July 10, 2021 16:57
C++ Concept Example
template<typename T, typename=void>
struct has_release : std::false_type {};
template<typename T>
struct has_release<T, decltype(std::declval<T>().Release())> : std::true_type {};
template<typename T>
class Wrapper {
T mData;
@vladiant
vladiant / CMakeLists.txt
Created June 6, 2021 11:55
CMake check project or subproject
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
# This is a typical pattern used by projects, to prevent
# their tests being built and run, if they are
# loaded as a sub-project
if(NOT DEFINED PROJECT_NAME)
set(NOT_SUBPROJECT ON)
else()
# turn NOT_SUBPROJECT off, in case it was already turned
# on in a parent scope:
@vladiant
vladiant / tp.md
Created July 3, 2021 12:35 — forked from shreve/tp.md
TP-Link Router Config Decrypt

TP-Link Router Config

Update 2021-04-29: This may still work for you if you've got an old TP-Link router, but this is not maintained and doesn't work with newer models. If you've got a newer router, other projects like tpconf_bin_xml will likely work better for you.

TP-Link allows you to backup and restore your router's config file. For some reason, they decided to encrypt these backups so you cannot modify them. I think this is dumb. This script lets you decrypt and re-encrypt your config files so you can modify them as you see fit.

I use this to modify my reserved addresses list because editing them through the web interface is terribly slow and cumbersome.

  1. Go to the router and download the config file from the "Backup & Restore" section of "System Tools".
  2. Run ruby tp.rb config.bin