Skip to content

Instantly share code, notes, and snippets.

View YigaoFan's full-sized avatar
💭
Programming, Working and Learning, will loving

范义高 YigaoFan

💭
Programming, Working and Learning, will loving
  • ShangHai, China
View GitHub Profile
// This is used to check if native JavaScript methods are overridden by a third-party source
function checkObject() {
['assign', 'create', 'defineProperty', 'defineProperties', 'entries', 'freeze',
'getOwnPropertyDescriptor', 'getOwnPropertyNames', 'getOwnPropertySymbols',
'getPrototypeOf', 'is', 'isExtensible', 'isFrozen', 'isSealed', 'keys',
'preventExtensions', 'seal', 'setPrototypeOf', 'values'].forEach(method => {
if (!Object[method]) {
console.warn(`Object.${method} method is missing.`);
} else if (Object[method].toString() !== `function ${method}() { [native code] }`) { // For Safari, the code is `function ${method}() {\n [native code]\n}`
@GorNishanov
GorNishanov / recursive_generator.h
Created March 15, 2017 16:03
recursive_generator implementation
#ifndef RECURSIVE_recursive_generator
#define RECURSIVE_recursive_generator
#include <experimental/coroutine>
// This class implements delegating (potentially recursive) recursive_generator.
// It supports two kind of yield expressions:
//
// co_yield V;
// co_yield G_of_T;
@utilForever
utilForever / SimpleReflection.cpp
Created August 25, 2016 01:54
Simple reflection on C++17 [Very simple approach to convert any struct (up to N members) to a tuple using C++17 structured bindings and the idea from Boost.DI]
#include <tuple>
#include <type_traits>
#include <cassert>
template <class T, class... TArgs> decltype(void(T{std::declval<TArgs>()...}), std::true_type{}) test_is_braces_constructible(int);
template <class, class...> std::false_type test_is_braces_constructible(...);
template <class T, class... TArgs> using is_braces_constructible = decltype(test_is_braces_constructible<T, TArgs...>(0));
struct any_type {
template<class T>
template <typename Left, typename Right>
struct ConcatExpr;
template <typename Left, typename Right>
struct AltExpr;
template <typename SubExpr>
struct RepeatExpr;
template <char ch>