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
| Meteor.setInterval (-> | |
| # console.log "Checking for old chats #{moment().subtract 10, 'seconds'}" | |
| # Delete stored chat elements older than threshold | |
| # meteor:PRIMARY> db.rooms.update({}, {$pull: {"chat":{date: {$lt: 1432208317490}}}}) | |
| room_collection.update {}, | |
| $pull: | |
| chat: | |
| date: | |
| $lt: moment().subtract(10, "seconds").valueOf(), |
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
| Template.Chat.helpers({ | |
| cached_chat: function() { | |
| console.log(this._id); | |
| console.log(local_chat_collections); | |
| console.log(local_chat_collections[this._id]); | |
| return local_chat_collections[this._id].find(); | |
| } | |
| }); |
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
| <template name='RoomUsers'> | |
| <div class='room_users'> | |
| {{log}} | |
| THIS FOO | |
| {{#each connected_users}} | |
| FOO THIS | |
| {{>RoomUser}} | |
| {{else}} | |
| WTF IS THIS | |
| {{/each}} |
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
| void subscribe(const std::string subject, std::function<void(Message *)> callback); | |
| template<typename T> | |
| void subscribe(std::function<void(T *)> callback) { | |
| this->subscribe(T::subject, [&](Message * message){ | |
| printf("In wrapping callback\n"); | |
| T * specific_message = dynamic_cast<T *>(message); | |
| if (specific_message != nullptr) { | |
| printf("About to call actual callback from wrapper\n"); | |
| callback(specific_message); |
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 <list> | |
| template<typename F> class Caller { | |
| public: | |
| F func; | |
| Caller(T func) : func(func) {} | |
| void call(MyClass o, list<int>, Ts... ts) { | |
| o.func(ts...); | |
| } | |
| }; |
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
| template<typename METHOD_TYPE> | |
| struct RunMethod {}; | |
| template<typename RETURN_TYPE, typename CLASS_TYPE, typename ... PARAMETERS> | |
| struct RunMethod<RETURN_TYPE(CLASS_TYPE::*)(PARAMETERS...)>{ | |
| typedef RETURN_TYPE(CLASS_TYPE::*METHOD_TYPE)(PARAMETERS...); | |
| CLASS_TYPE object; | |
| METHOD_TYPE method; | |
| RunMethod(CLASS_TYPE object, METHOD_TYPE method) : object(object), method(method) {} |
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
| 05 | |
| template <class T> | |
| 06 | |
| class Singleton | |
| 07 | |
| { | |
| 08 | |
| public: | |
| 09 | |
| static T* Instance() { |
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
| template <class T> | |
| class Singleton | |
| { | |
| public: | |
| static T* Instance() { | |
| if(!m_pInstance) m_pInstance = new T; | |
| assert(m_pInstance != NULL); | |
| return m_pInstance; | |
| } | |
| protected: |
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
| template<typename METHOD_TYPE> | |
| struct RunMethod {}; | |
| template<typename RETURN_TYPE, typename CLASS_TYPE, typename ... PARAMETERS> | |
| struct RunMethod<RETURN_TYPE(CLASS_TYPE::*)(PARAMETERS...)>{ | |
| typedef RETURN_TYPE(CLASS_TYPE::*METHOD_TYPE)(PARAMETERS...); | |
| CLASS_TYPE & object; | |
| METHOD_TYPE method; |
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
| template<typename T> | |
| struct CastToNative {}; | |
| template<> | |
| struct CastToNative<int> { | |
| int operator()(Local<Value> value){return value->ToInteger()->Value();} | |
| }; | |
| template<> | |
| struct CastToNative<char *> { | |
| char * operator()(Local<Value> value){return *v8::String::Utf8Value(value);} |
OlderNewer