This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef VARIANT | |
#define VARIANT | |
// Quick implementation of variant type, somewhat like boost::variant. | |
// Why not using boost then ? Boost is a big dependency, using it on such a tiny code | |
// would not be wise. | |
// NOTE : Is uint64 wise here ? I just chose it for security purpose | |
// Maybe using constexpr here would be wise. I don't want it to sound like a template metaprogramming showoff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef VARIANT | |
#define VARIANT | |
// Quick implementation of variant type, somewhat like boost::variant. | |
// Why not using boost then ? Boost is a big dependency, using it on such a tiny code | |
// would not be wise. | |
// NOTE : Is uint64 wise here ? I just chose it for security purpose | |
// Maybe using constexpr here would be wise. I don't want it to sound like a template metaprogramming showoff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x=[1000:9999]; | |
v=zeros(1,9000); | |
v=v+floor(x./1000).^4; | |
v=v+(floor(x./100)-floor(x./1000)*10).^4; | |
v=v+(floor(x./10)-floor(x./100)*10).^4; | |
v=v+(x-floor(x./10)*10).^4; | |
v(find(v==x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This algorithm is based on a very popular algorithm among C programmers, used to calculate power of | |
a number. I used a tail recursivity, as I wanted it to be C++11 compliant, and thus I had no | |
unconstrained constexpr, thus no loops. | |
The algorithm is based on this simple observation : | |
for instance, we want to compute 6^7. We have that 6^7 = 6*(6^3*6^3) = 6*(6*(6^2)*6*(6^2)) | |
We can see that there's some pattern in the expression. To see things more clearly, we can rewrite | |
the expression as follow: | |
6^7 = 6*6^2*(6^2)*(6^2) | |
Actually, the algorithm is doing the opposite order of the decomposition. That make sens as | |
we are starting from the base. To summarize the algorithm way of functionning, I would say the following : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdint> | |
int64_t number = 0; | |
int64_t index = 0; | |
int main() | |
{ | |
while(true) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<size_t last> | |
void printNumbers() | |
{ | |
std::cout << last << std::endl; | |
} | |
template<size_t head1, size_t head2, size_t... tail> | |
void printNumbers() | |
{ | |
std::cout << head1 << std::endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "hello.hxx" | |
using namespace Dante; | |
int main() | |
{ | |
AlphaMan Benzaie; | |
Benzaie.KILLECVERYTINGBHLAAAAH(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct | |
# I do not support Decimal type in this toy code | |
# This piece of code should just work on python2 and python3 | |
# In general, it will work for single precision, IEEE754 compliant floating point numbers | |
# Dirty function to avoid having to type the condition in each function | |
def throwOnNonFloat(num): | |
if not(type(num) is float): | |
raise ValueError(str(num) + " is not a floating point number !") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Test where | |
-- NOTE : I just write every type as training purpose | |
-- List used for testing purpose | |
-- Main testing list | |
mahList :: [Integer] | |
mahList = [1, 2, 3, 4, 65, 8779 , 11, 64, 15 , 48] | |
-- List used for rmDup, asit contains a lot of duplicates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef COMMON_CORE_UTILITY_LOGGER | |
#define COMMON_CORE_UTILITY_LOGGER | |
#include <iostream> | |
/* This logger library attempts to be simple, but as extensible as possible, and as | |
* easy to use as possible. Performance is also taken in account, even if it's not | |
* the main reason for writing this. | |
* The ultimate goal is to achieve a clean interface, as easy to use as possible |
OlderNewer