Saturday, October 22, 2016

Nibble 2 for Operating Systems and Architecture

Q: How do clustered systems differ from multiprocessor systems? 
What is required for 2 machines belonging to a cluster to cooperate to provide a highly available service?

A: Clustered systems are typically constructed by combining multiple computers into a single system to perform a computational task distributed across the cluster.
Multiprocessor systems on the other hand could be a single entity comprising of multiple CPUs.
A clustered system is less tightly coupled than a multiprocessor system. 
Clustered systems communicate using messages, while processors in a multiprocessor system communicate using shared memory. 
In order for 2 machines to provide a highly available service, the state on the two machines should be replicated and should be consistently updated. When one of the machines fails, the other could then take over the functionality of the failed machine.

Nibble 1 for Operating Systems and Architecture

Q: A password may become known to others in a variety of ways. Is there a simple method for detecting that such an event has occurred?

A: Whenever a user logs in, the system prints the last time that user was logged in to the system.

Wednesday, September 14, 2016

AdMob and CustomAds Helpers for Swift and SpriteKit etc.

If you ever need to integrate AdMob ads into your SpriteKit game or Swift app, these helper classes are very useful:

They make it easy to display ad banners wherever you like in your app, e.g. in a Game Over scene.

Thanks to crashoverride777.

Monday, May 2, 2016

UNISA COS3711 Practice: XML

Given the class definitions and sample XML file below, write code for the constructor and addAnimal() function of AnimalWriter to append the state of an Animal object to the XML document maintained by the animalWriter class (so that it follows the XML example given below).







Saturday, June 6, 2015

Thursday, May 14, 2015

Some Qt and C++ tickles for UNISA COS2614

Qt software
Some simple things to remember for the UNISA COS2614 exam, in no particular order:

Download Qt here:

Nice simple Qt examples here:

C++ if-else shorthand (ternary operators): 
condition ? value_if_true : value_if_false

Command Line Arguments: 
int main ( int argc, char *argv[] )
The integer, argc is the ARGument Count (hence argc). It is the number of arguments passed into the program from the command line, including the name of the program.

The array of character pointers is the listing of all the arguments. argv[0] is the name of the program, or an empty string if the name is not available. After that, every element number less than argc is a command line argument. You can use each argv element just like a string, or use argv as a two dimensional array. argv[argc] is a null pointer.

Explain two benefits of applying design patterns in OOP:
Improves re-usability and extensibility of software.
  • Re-usability - want to be able to re-use relevant bits of code in the simplest way possible. Design patterns attempt to express similar code in an abstract way, this allows for code reuse. We are able to design abstract classes in a way that allows us to derive from these classes and use similar code, this promotes code reusability.
  • Extensibility - how easy is it to add enhancements to an app. Design patterns also promote extensibility. A measure of how easy it is to add improvements to an application and one way of making code extensibility is to provide classes which can easily be sub-classed. Qt framework is a good example of this.


The keyword explicit can be placed before a single argument constructor in the class
definition to prevent automatic conversion from being used by the compiler. This is useful if the argument is not anything like the class it is constructing, or if there is something akin to a parent-child relationship between them.
Classes generated by QtCreator place this keyword before the generated custom widget constructors, and it is advisable that you do the same with your QWidget -derived classes.
(The keyword explicit prevents the compiler from automatically using that constructor for implicit type conversions.)

Stack and Heap stuff:
When QObjects are created with new, they are created on the heap.
Otherwise they are created on the stack.

Polymorphic Assignment:
Polymorphic assignment allows a pointer of type superclass to point to objects of its concrete subclasses.

QMessageBox::information (0, "String Reverse", reversed);

Very Simple Random number generator:

int main()
QTextStream cout(stdout);

int random = qrand() % 5;
cout << "Random number: " << random << endl;

return 0;

Very simple SIGNALS and SLOTS example:
//include necessary pre-processor directives here

int main(int argc, char *argv[]){
QApplication a(argc, argv);
QWidget w;
QLabel *label = new QLabel("Enter Text:");
QLineEdit *input = new QLineEdit("Hello");
QPushButton *clear = new QPushButton("Clear");
QVBoxLayout *layout = new QVBoxLayout();
QObject::connect(clear, SIGNAL(clicked()), input, SLOT(clear()));;
return a.exec();

What is the difference between a function declaration and a function
A function declaration describes how a function can be called.
A function definition includes the actual code that is to be executed.

Sunday, November 23, 2014

Free 3D coffee grinder

Grab this cool model for free over at turbosquid

  • Made by Turbosquid user PlastyForma
  • Created in 3ds Max 8, has V-Ray materials


3D models