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 / cpp03.cpp
Created March 21, 2022 20:42
Evolving a Nice Trick - Patrice Roy - CppCon 2021
#include <cmath>
class exact {};
class floating {};
template <class T> bool close_enough(T a, T b, exact) {
return a == b;
}
template <class T> bool close_enough(T a, T b, floating) {
return std::abs(a - b) <= static_cast<T>(0.000001);
}
struct false_type { enum { value = false }; };
@vladiant
vladiant / downloader.py
Created March 13, 2022 12:17
imgbox.com gallery downloader
import urllib.request
import requests
from bs4 import BeautifulSoup
with open("images.txt", "r") as fp:
lines = fp.readlines()
for url in lines:
r = requests.get(url=url.strip())
print(f"URL: {url.strip()}")
@vladiant
vladiant / computer_vision_perception_self_driving_cars.txt
Created March 8, 2022 21:18
Computer Vision and Perception for Self-Driving Cars (Deep Learning Course)
Computer Vision and Perception for Self-Driving Cars (Deep Learning Course)
https://www.youtube.com/watch?v=cPOtULagNnI
Python + Deep Learning
Robotics with Sakshay
https://www.youtube.com/c/roboticswithsakshay/videos
* Road Segmentation
* 2D Object Detection (yolo)
@vladiant
vladiant / compare_ml.py
Created February 28, 2022 18:56
Compare ML algorithms
# Compare Algorithms
import pandas
import matplotlib.pyplot as plt
from sklearn import model_selection
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
from sklearn.naive_bayes import GaussianNB
from sklearn.svm import SVC
@vladiant
vladiant / compile_time_check_user_literals.cpp
Created November 17, 2021 18:31
Compile time checking user defined literals
// With friendly permission of BENOCS GmbH (www.benocs.com)
// https://www.youtube.com/watch?v=KmoTKz95Wsg
// https://godbolt.org/z/73vT1bE86
#include <cstdio> // Needed for the print-function only!
#include <cstdint>
#include <variant>
#include <system_error>
@vladiant
vladiant / client.py
Created August 14, 2021 20:57
Python DBus
#!/usr/bin/env python3
import dbus
class Client:
def __init__(self):
bus = dbus.SessionBus()
service = bus.get_object("com.example.service", "/com/example/service")
self._message = service.get_dbus_method(
@vladiant
vladiant / qa-warnings.cmake
Created August 14, 2021 19:18
C++ compiler flags
# NOTE: all useful flags for up to GCC 8.1 and Clang 7.0 were added (not included into -Wall -Wextra)
# * https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
# * https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html
# * https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html
# * https://clang.llvm.org/docs/DiagnosticsReference.html
set(qa_warn)
set(qa_c_warn)
set(qa_cxx_warn)
@vladiant
vladiant / Makefile
Created July 10, 2021 22:12
C++20 Hello World Module
main : main.o hello.o
g++-11 -o main main.o hello.o
main.o : main.cpp gcm.cache/smd.hello.gcm
g++-11 -fPIC -fmodules-ts -std=c++20 -o main.o -c main.cpp
hello.o: hello.cpp
g++-11 -fPIC -fmodules-ts -std=c++20 -o hello.o -c hello.cpp
gcm.cache/smd.hello.gcm: hello.o
@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
@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: