Skip to content

Instantly share code, notes, and snippets.

View JohnMurray's full-sized avatar

John Murray JohnMurray

View GitHub Profile
@JohnMurray
JohnMurray / unload-keyboard
Created February 20, 2012 12:34
Disable Mac OS X Keyboard (built-in only)
#!/bin/bash
# Unload the keyboard so I can use my external keyboard
# and not worry about accidentally pressing buttons on
# the built-in. This may not be a problem for you but, you
# should see my desk sometimes (Oh no!!) ;-)
sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/

Nim Learning List

template<std::derived_from<Actor> RefOf>
class ActorRef { /* ...
template<typename RefOf>
class ActorRef {
std::shared_ptr<RefOf> m_actor;
public:
ActorRef(std::shared_ptr<RefOf> actor)
: m_actor(actor) {}
template<typename Message>
void send(Message&& msg) { /* TODO */ }
}
int main() {
std::unique_ptr<Actor> actor = std::make_unique<HelloActor>("Howdy");
actor->enqueue([&actor]() {
// how do I get it to the correct receiver?
dynamic_cast<HelloBehavior*>(actor.get())->receive("neighbor");
});
actor->process_message();
}
class Actor {
public:
virtual ~Actor() = default;
};
class Behavior {};
class Actor {
std::deque<std::function<void()>> m_messages;
public:
virtual ~Actor() = default;
void enqueue(std::function<void()> const& func) {
m_messages.push_back(func);
}
class HelloActor
: Actor<std::string>
, HelloBehavior { ... }
template<typename ... Messages>
class Actor {
std::vector<std::variant<Messages ...>> m_messages;
};
class HelloBehavior {
public:
virtual void receive(std::string const& msg) = 0;
};
class HelloActor
: public Actor
, public HelloBehavior {
std::string m_greeting;