Skip to content

Instantly share code, notes, and snippets.

View dpogue's full-sized avatar
👨‍💻
I may be slow to respond.

Darryl Pogue dpogue

👨‍💻
I may be slow to respond.
View GitHub Profile
#!/usr/bin/env python
import os, sys, gobject, dbus, pynotify
from dbus.mainloop.glib import DBusGMainLoop
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
def recv_chat(account, sender, message, conversation, flags):
if not bus.pidginbus.PurpleConversationHasFocus(conversation):
class MyGraphicsComponent : public GraphicsComponent
{
Q_OBJECT
public slots:
void draw(MyObject* obj) {
/* Qt draws some stuff */
}
};
@dpogue
dpogue / mainwindow.cpp
Created February 8, 2011 05:43
MainWindow class for the client-side of td
#include "mainwindow.h"
#include "util/thread.h"
namespace td {
MainWindow::MainWindow() : QMainWindow() {
driver_ = new CDriver(this);
/* Somehow get the driver running in its own thread(?) */
scene_ = new QGraphicsScene();
@dpogue
dpogue / Makefile
Created February 9, 2011 05:39
make test command (example)
test: all
@for f in ./tests/*; \
do \
stderr=$$( ./bin/pycdc "$$f" 2>&1 1>/dev/null ); \
if [ "$$?" -eq "0" -a -z "$$stderr" ]; then \
echo "\033[32mPASSED\033[m $$f"; \
else \
echo $$stderr; \
echo "\033[31mFAILED\033[m $$f"; \
fi \
from socket import *
t = socket(AF_INET, SOCK_STREAM)
t.bind(('127.0.0.1', 8000))
t.listen(5)
while 1:
a = t.accept()
a[0].recv(1024)
diff --git a/src/client/main.cpp b/src/client/main.cpp
index 505064c..86ced05 100644
--- a/src/client/main.cpp
+++ b/src/client/main.cpp
@@ -14,6 +14,11 @@ int main(int argc, char **argv) {
/* Set working directory */
bin.cdUp();
+#if defined(Q_WS_MAC)
+ bin.cdUp(); /* Fix this on Mac because of the .app folder, */
Device Drivers use interrupt-driven IO
Top half of a driver is kernel stuff
Bottom half of a driver is device stuff
When we ls -l /dev, the first character indicates the file type:
- normal file
d directory
p pipe
l link
diff --cc src/engine/Player.cpp
index f160626,b6f9ab2..0000000
--- a/src/engine/Player.cpp
+++ b/src/engine/Player.cpp
diff --cc src/engine/SDriver.cpp
index 623c87c,07db559..0000000
--- a/src/engine/SDriver.cpp
+++ b/src/engine/SDriver.cpp
@@@ -51,18 -51,18 +51,21 @@@ void SDriver::updatePlayer(Player* p1,
@dpogue
dpogue / valgrind.log
Created March 11, 2011 08:50
Valgrind log for td
==27165== Invalid read of size 8
==27165== at 0x412928: QListData::isEmpty() const (qlist.h:95)
==27165== by 0x41BDB3: QList<td::NPC*>::isEmpty() const (qlist.h:139)
==27165== by 0x41BE49: QList<td::NPC*>::first() (qlist.h:269)
==27165== by 0x41AA73: td::CDriver::NPCDeleter() (CDriver.cpp:170)
==27165== by 0x433B5B: td::CDriver::qt_metacall(QMetaObject::Call, int, void**) (moc_CDriver.cpp:90)
==27165== by 0x6A6ABDD: QObject::event(QEvent*) (qobject.cpp:1219)
==27165== by 0x5A90FDB: QApplicationPrivate::notify_helper(QObject*, QEvent*) (qapplication.cpp:4396)
==27165== by 0x5A96AEC: QApplication::notify(QObject*, QEvent*) (qapplication.cpp:4277)
==27165== by 0x6A58CDB: QCoreApplication::notifyInternal(QObject*, QEvent*) (qcoreapplication.cpp:732)
@dpogue
dpogue / gist:867047
Created March 12, 2011 05:04
Tower subtype example
/* SDriver.cpp */
Tower* SDriver::createTower(TowerType subtype) {
Tower* tower = (Tower*)mgr_->createObject(Tower::clsIdx());
tower->setType(subtype);
tower->initComponents();
return tower;