Skip to content

Instantly share code, notes, and snippets.

💻
compiling...

Ivan Sanz Carasa isc30

💻
compiling...
Block or report user

Report or block isc30

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View sparsevector.cpp
#include <iostream>
#include <vector>
#include <string>
using namespace std;
class SparseVector
{
private:
std::vector<bool> orderVec;
std::vector<int> valueVec;
View polymorphic_get.hpp
template<typename TBase, typename... Types>
constexpr auto polymorphic_get(std::variant<Types...>& v)
-> std::enable_if_t<(std::is_base_of_v<TBase, Types> && ...), TBase&>
{
return *std::visit([](auto& x){ return dynamic_cast<TBase*>(&x); }, v);
}
@isc30
isc30 / download_binary.js
Last active Aug 26, 2018
downloading binary data as a file
View download_binary.js
function download_binary(binaryData, fileName, mime)
{
file = new Blob([binaryData], { type: mime });
downloadUrl = URL.createObjectURL(file);
// download the Blob
anchor = document.createElement('a');
anchor.download = fileName;
anchor.href = downloadUrl;
anchor.dataset.downloadurl = mime + ":" + fileName + ":" + downloadUrl;
@isc30
isc30 / callable.hpp
Last active Sep 2, 2018
template-based wrapper for any callable with signature + metadata traits
View callable.hpp
#pragma once
#include <type_traits>
#include <functional>
template<typename TCallable, typename TSignature>
constexpr bool is_callable_as_v = std::is_constructible<std::function<TSignature>, TCallable>::value;
template<
typename TCallable,
@isc30
isc30 / triangle.cpp
Last active Aug 11, 2018 — forked from SuperV1234/hello_triangle.cpp
SDL2 + WebGL 2.0 = Triangle
View triangle.cpp
#include <iostream>
#include <exception>
#include <functional>
#include <vector>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
#ifndef __EMSCRIPTEN__
View conceptsV2.cpp
#include <iostream>
#include <vector>
#include <type_traits>
#include <tuple>
namespace sfinae
{
using success = std::true_type;
using fail = std::false_type;
@isc30
isc30 / ApplyTuppleArrayVector.cpp
Last active Jan 31, 2018
C++14 helpers to call functor using args stored in a tuple, array or vector
View ApplyTuppleArrayVector.cpp
#include <iostream>
#include <array>
#include <vector>
#include <tuple>
#include <utility>
void printNumbers(int x, int y, int z)
{
std::cout << x << std::endl;
std::cout << y << std::endl;
View Notes for GMock.md

Mock const methods

Use MOCK_CONST_*

Mock constructor

Simply call base constructor with custom params

Mock private or protected methods

C++ allows redefining access level on subclasses, so mocks should have everything as PUBLIC

class Loler
View Notes for GUnit.md

Google Test - Unit

Disabling a Test

Add DISABLED_ prefix to test name

Floating point comparisons

Use EXPECT_FLOAT_EQ

Running the tests

main.cpp

#include <gtest/gtest.h>
View extract.js
var area = 7;
// BLUE
/*var color = [
0, 220, 220,
35, 255, 255
];*/
// YELLOW
var color = [
You can’t perform that action at this time.