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
var Promise = require('promise'); | |
function* counter(){ | |
let i=0; | |
while(1){ | |
yield i++; | |
} | |
} | |
function wait(time){ |
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
function extend(...args) { | |
let obj = this||{}; | |
const l = args.length; | |
for (let i=0; i < l; i++) { | |
for (let k in args[i]) { | |
obj[k] = args[i][k]; | |
} | |
} | |
return obj; | |
} |
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> | |
using namespace std; | |
template<class Getter> | |
struct VectorF { | |
const size_t N; | |
Getter Get; | |
template<class T> |
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 <type_traits> | |
#include <iostream> | |
using namespace std; | |
auto Valid = [](auto...x) -> integral_constant<bool,1> {}; | |
template<class F,class...X> | |
constexpr auto is_callable(F f,X...x) | |
-> decltype( f(x...), true_type{} ) { | |
return{}; |
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 <array> | |
#include <tuple> | |
#include <type_traits> | |
#include <algorithm> | |
using namespace std; | |
auto Valid = [](auto...x) -> integral_constant<bool,1> {}; |
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
function inviteAll(i, clickTime, loadTime) { | |
i = (i !== undefined) ? i : 100; // how many people you like to add ? | |
clickTime = clickTime||350; // how quick can a human click ? | |
loadTime = loadTime||1000; // wait till next page is loaded | |
if (i<=0) return; | |
var invite = document. | |
querySelector('a[href^="/people/invite"]:not(.invite-sent)'); | |
// check if there a people to invite | |
if (invite) { | |
invite.click(); |
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
// Fibonacci | |
#include<math.h> | |
#include<vector> | |
// This slow machine will barely be able to compute Fib1(30) | |
// O(n!) | |
constexpr auto FibR(size_t n) { |
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
// Type Erasure | |
// https://channel9.msdn.com/Events/GoingNative/2013/Inheritance-Is-The-Base-Class-of-Evil | |
// https://akrzemi1.wordpress.com/2013/11/18/type-erasure-part-i/ | |
#include<memory> | |
#include<iostream> | |
struct Printable { | |
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
//SFINAE - Substitution-Failure-Is-Not-An-Error | |
template<bool condition, class T> | |
struct enable_if { | |
using type = T; | |
}; | |
template<class T> | |
struct enable_if<false,T> |
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<vector> | |
#include<string> | |
#include<set> | |
auto numberOfUniqueChars(std::string const& str) { | |
std::set<char> s; | |
for(auto c : str) { | |
s.insert(c); | |
} |
OlderNewer