Skip to content

Instantly share code, notes, and snippets.

View yeputons's full-sized avatar

Egor Suvorov yeputons

  • Saint-Petersburg, Russia
View GitHub Profile
cmake_minimum_required(VERSION 3.22)
project(cmake-issue-demo CXX)
add_executable(exec main.cpp)
set(ARGS ARG1 "value1" ARG2 "$<$<CONFIG:Debug>:value2>" ARG3 "value3")
add_custom_command(
TARGET exec POST_BUILD
COMMAND "${CMAKE_COMMAND}"
-D "ARGS=${ARGS}"
-P "${CMAKE_CURRENT_SOURCE_DIR}/helper.cmake"
VERBATIM
@yeputons
yeputons / CMakeLists.txt
Last active May 26, 2023 21:23
CMake dynamic library example
cmake_minimum_required(VERSION 3.10)
project(dynamic-library-example CXX)
add_library(lib SHARED lib.cpp)
add_executable(app app.cpp)
target_link_libraries(app lib)
# cmake -B build-dir
# cmake --build build-dir
@yeputons
yeputons / indices.cpp
Created September 24, 2021 16:28
Indices vs pointers
#include <iostream>
struct node {
int value; // Данные в узле
int prev = -1; // Номер предыдущего узла в массиве
int next = -1; // Номер следующего узла в массиве
};
node nodes[1'000'000]; // Завели себе миллион нод
int main() {
#include <stdio.h>
#include "lib.h"
double f0(void) {
return 123;
}
double f2(double a, double b) {
return a + b;
}
@yeputons
yeputons / CMakeLists.txt
Created March 29, 2021 17:23
GCC's include option with CMake
cmake_minimum_required(VERSION 3.10)
project(gcc-include-demo CXX)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Make sure it's specified before add_executable.
# Includes pre-main.inc.cpp in all translation units in all projects.
# Use target_compile_options to include it in all translation units for a specific target only.
add_compile_options(-include pre-main.inc.cpp)
else()
@yeputons
yeputons / build-run.sh
Last active March 8, 2024 19:25
Emscripten's embind's std::vector<std::string> example (tested with emscripten 2.0.6)
#!/bin/bash
em++ --bind cpp-code.cpp --post-js js-code.js -o output.js
node output.js
#include <iostream>
#include <vector>
#include <algorithm>
void make_good() {
}
// #define vector<int> vi
using vi = std::vector<int>;
Request URL: https://notify.travis-ci.org
Request method: POST
content-type: application/x-www-form-urlencoded
Expect:
User-Agent: GitHub-Hookshot/730b3b3
X-GitHub-Delivery: 4ff8db00-33f3-11ea-9683-718fa20b1245
X-GitHub-Event: pull_request
@yeputons
yeputons / 01_implicit_params.scala
Last active December 5, 2018 17:49
Scala examples on 05.12.2018
case class Context(canRead: Boolean)
val pages = Map(
1 -> "Hello",
2 -> "World"
)
def getPage(id: Int)(implicit context: Context): Option[String] =
if (context.canRead)
pages.get(id)
workspace(name = "my_test")
local_repository(
name = "tf_serving",
path = "serving",
)
local_repository(
name = "org_tensorflow",
path = "serving/tensorflow",