This file contains hidden or 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 "single_instance.hpp" | |
| using namespace std; | |
| class A : public enable_single_instance<A> | |
| { | |
| friend class enable_single_instance<A>; | |
| public: |
This file contains hidden or 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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
This file contains hidden or 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 <memory> | |
| #include "MVar.hpp" | |
| template <typename T> | |
| struct Item; | |
| template <typename T> | |
| struct Stream | |
| { | |
| typedef MVar<Item<T>> type; |
This file contains hidden or 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 <cassert> | |
| #include <functional> | |
| #include <iostream> | |
| #include <memory> | |
| #include <string> | |
| #include <vector> | |
| using namespace std; | |
| int inverter_delay = 2; |
This file contains hidden or 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
| #define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL(__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1) | |
| #define VA_NUM_ARGS_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, N, ...) N | |
| #define MACRO_DISPATCHER(func, ...) MACRO_DISPATCHER_(func, VA_NUM_ARGS(__VA_ARGS__)) | |
| #define MACRO_DISPATCHER_(func, nargs) MACRO_DISPATCHER__(func, nargs) | |
| #define MACRO_DISPATCHER__(func, nargs) func ## nargs | |
| #define VAR1(x) L ## #x" = " << x | |
| #define VAR2(x, ...) L ## #x" = " << x << L", " << VAR1(__VA_ARGS__) | |
| #define VAR3(x, ...) L ## #x" = " << x << L", " << VAR2(__VA_ARGS__) |
This file contains hidden or 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 "Log.h" | |
| #include <tchar.h> | |
| namespace Log | |
| { | |
| __declspec(thread) Checkpoint* Checkpoint::s_pTop = NULL; | |
| __declspec(thread) bool Checkpoint::exception_handled = false; | |
| void PrintF_Internal(PCTSTR szFmt, const int* pParams, PTSTR szBuf, size_t nLenBuf, size_t nData) |
This file contains hidden or 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
| #pragma once | |
| #include <mutex> | |
| #include <condition_variable> | |
| #include <queue> | |
| using namespace std; | |
| template <typename T> | |
| class BlockingQueue |
This file contains hidden or 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 Main where | |
| -- 是否存在重复的元素 | |
| -- [1,2,3] -> False | |
| -- [1,1,3] -> True | |
| isUnique :: (Eq a) => [a] -> Bool | |
| isUnique = isUnique' [] | |
| isUnique' :: (Eq a) => [a] -> [a] -> Bool | |
| isUnique' _ [] = True |
This file contains hidden or 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
| {-# LANGUAGE GADTs #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE PolyKinds #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| module Unit where | |
| import qualified Prelude as P | |
| import Prelude hiding ((+), (*), (/), (-), Int, pi) |
This file contains hidden or 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
| -- http://blog.tmorris.net/posts/20-intermediate-haskell-exercises/ | |
| module Main where | |
| class Fluffy f where | |
| furry :: (a -> b) -> f a -> f b | |
| -- Exercise 1 | |
| -- Relative Difficulty: 1 | |
| instance Fluffy [] where | |
| furry _ [] = [] |