Skip to content

Instantly share code, notes, and snippets.

@jbandela
jbandela / cargo_x86_64-unknown-linux-gnu-on-m1-mac.sh
Created February 15, 2023 19:42 — forked from shqld/cargo_x86_64-unknown-linux-gnu-on-m1-mac.sh
cargo build for the target x86_64-unknown-linux-gnu on M1 Mac
# https://github.com/messense/homebrew-macos-cross-toolchains
brew tap messense/macos-cross-toolchains
brew install x86_64-unknown-linux-gnu
export CC_X86_64_UNKNOWN_LINUX_GNU=x86_64-unknown-linux-gnu-gcc
export CXX_X86_64_UNKNOWN_LINUX_GNU=x86_64-unknown-linux-gnu-g++
export AR_X86_64_UNKNOWN_LINUX_GNU=x86_64-unknown-linux-gnu-ar
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-unknown-linux-gnu-gcc
@jbandela
jbandela / polymorphic_view.cpp
Last active August 10, 2018 23:28
Polymorphic View
// Copyright 2018 Google LLC.
// SPDX-License-Identifier: Apache-2.0
#include <array>
#include <utility>
namespace polymorphic {
namespace detail {
template <typename T, typename Signature>
struct function_entry;
//Copyright 2017 Google Inc.
//
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//https ://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
@jbandela
jbandela / factorial.cpp
Created December 15, 2015 16:27
Precomputed factorial
#include <numeric>
template<class T>
constexpr T cfact(unsigned f) {
return f?cfact<T>(f - 1)*f : 1;
}
template<class T>
constexpr T factorial_max_helper(T value_so_far, unsigned f) {
#include <tuple>
#include <utility>
#include <cstdint>
#include <stdexcept>
using std::size_t;
template<typename F, typename Tuple, size_t... I>
auto
apply_(F&& f, Tuple&& args, std::integer_sequence<size_t,I...>)
@jbandela
jbandela / set_iterators.cpp
Last active August 29, 2015 14:07
set_iterators
#include <boost/iterator/iterator_facade.hpp>
#include <boost/range/iterator_range.hpp>
#include <iterator>
#include <utility>
template<class Iter1, class Iter2,class Comp>
struct set_intersection_iterator:public boost::iterator_facade<set_intersection_iterator<Iter1,Iter2,Comp>,const typename std::iterator_traits<Iter1>::value_type,std::forward_iterator_tag>
{
Iter1 begin1_;
Iter1 end1_;
#include <iostream>
#include <typeinfo>
// Would go into operator_auto.hpp
namespace operator_auto {
struct operator_auto_imp {
template <class T>
@jbandela
jbandela / QT5.2
Last active December 27, 2015 06:49
How to build QT 5.2 with MSVC 2013 Release Static
1) Download
2) extract zip file
3) set DXSDK_DIR= \um\
4) Edit "C:\Users\jrb\Downloads\qt-everywhere-opensource-src-5.2.0-beta1\qt-everywhere-opensource-src-5.2.0-beta1\qtbase\mkspecs\win32-msvc2013\qmake.conf" and change MT to MD
5) C:\Users\jrb\Downloads\qt-everywhere-opensource-src-5.2.0-beta1\qt-everywhere-opensource-src-5.2.0-beta1\qtbase\src\angle\src\libGLESv2\Makefile.Release and replace "c:\program files ..\fxc" with fxc
6) C:\Users\jrb\Downloads\qt-everywhere-opensource-src-5.2.0-beta1\qt-everywhere-opensource-src-5.2.0-beta1\qtbase\src\3rdparty\angle\src\libEGL\Surface.cpp add #include <algorithm>
7) In "C:\Users\jrb\Downloads\qt-everywhere-opensource-src-5.2.0-beta1\qt-everywhere-opensource-src-5.2.0-beta1\qtdeclarative\src\3rdparty\masm\yarr\YarrParser.h"
Add definitions for declarations from C:\Users\jrb\Downloads\qt-everywhere-opensource-src-5.2.0-beta1\qt-everywhere-opensource-src-5.2.0-beta1
\qtscript\src\3rdparty\javascriptcore\JavaScriptCore\yarr\RegexCompiler.cpp
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
#include <cppcomponents_libuv/cppcomponents_libuv.hpp>
#include<vector>
using namespace cppcomponents_libuv;
using namespace cppcomponents;
#include <memory>
#include <string>
#include <iostream>
struct Base{
protected: