Archive for October, 2007

MySQL, Source Code, php

MySQLDump 2.0

This is a guest post from Daniele

After a lot of work, I released the new version (2.0) of the MySQLDump class, already introduced by this article.
MySQLDump is a class that allows to do a complete MySQL database backup with php pages.

After the inandrea’s good work there wasn’t too much space for improvements, but I think that these addition can be usefull: now it’s possible to export structures and/or data not only for the selected database but also for a single table.

The following example will explain how to export the structure and the data for the table mytable in the db mydb (the interface to the class is slightly changed from the previous version).

//Include the library
@include_once('lib_dump.php');
//Db connection
$connection = @mysql_connect('127.0.0.1','username','password');
//Create the MySQLDump class instance
//1° parameter: db name
//2° parameter: the exported file that will contain the dump
//3° parameter: create zipped file (true = zipped, false = normal)
//4° parameter: data encode (true = hexadecimal, false = plain text)
$dumper = new MySQLDump('mydb','dumpfile.sql',false,false);
//Structure export of the table 'mytable'
$dumper->getTableStructure('mytable');
//Data export of the table 'mytable'
$dumper->getTableData('mytable');

Continue Reading »

C, Quiz

Coders4fun Quiz #1

What will be printed using this c++ code?

#include <iostream>

int main()
{
	int i = 0;
	for (i = i == 0; i < 9; i = 1 + i * 2);
		std::cout<<i<<std::endl;
	return 0;
}

Please don’t cheat using a compiler! :)

P.S.
Of course the example compiles!

C, Source Code, UDP Communication

UDPListener: Receiving UDP messages in C#

This post is part of the UDPCommunication project.

UDP - User Datagram Protocol

The class in this post allows, in an easy and fast manner, to receive UDP messages. You don’t need to be a socket expert to use the class, cause you only need to write few rows of code to use it. Following, a little example showing how to use the class:

private void InitConnection()
{
	m_udpListener = new UDPListener(m_port, new byte[4] { 0, 0, 0, 0 });
	m_udpListener.MessageReceived += new UDPMessageReceivedDelegate(udpListener_MessageReceived);
}

Continue Reading »

News, Site

W Firefox! :D

This post is dedicated to all non-IE users of coders4fun:
firefox batte ie

THANKS!!

C, Source Code, Windows

Reboot or Shutdown a pc

This is a little how-to that explains how to shutdown or reboot a Windows machine in c++ .
In the source code you will find the function ShutDown, definied as follow:

bool ShutDown(bool restart)

The function shutdowns or reboots the pc, and returns false if the shutdown can’t be done (for example a process denied the power off).

Shut Down

So, to shutdown the pc, you only have to call the function and check if the shutdown was done.

if (!ShutDown(false))
{
	// shutdown not done.
}

Part of source code following:
Continue Reading »

C, Source Code, UDP Communication

UDPSender: Sending UDP messages in C#

This post is part of the UDPCommunication project.

Header UDP

This is a class that allows to send UDP messages in C# with an unbelievable semplicity.
To create the class you only need to create it, specifying a port for the udp communication, eg 3125 in this case:

try
{
	INetworkSender udpSender = new UDPSender(3125)
}
catch(UDPSenderException e)
{
        	// error during the socket initialization
}

Sending a message to an host is simple: call the SendMessage method specifying the receiver (with an host name, like “www.coders4fun.com“, or with an ip, like “192.168.10.6“) and a byte array containing the message.
Continue Reading »

News, Source Code, Wiki-Dashboard, Wordpress, php

Wordpress Plugin: Wiki-Dashboard 0.1

Wiki-Dashboard is a Wordpress plugin that allows to all registered user on a blog to share and edit a text like a wiki, and can be usefull even on mono-author blogs, giving a space to write notes.

Features:

  • Dashboard subpage with the text where to put notes
  • Text shared to all blog authors
  • bbCode parser for text formatting
  • Internationalization support

Installation:
Simply download the Zip-Archive and extract all files into your wp-content/plugins/ directory. Then go into your WordPress administration page, click on Plugins and activate it.
After that you will have a new submenu called “Wiki” under the “Dashboard” menu.

Download Wiki Dashboard 0.1. Downloads: 2694

Screenshots:
Wiki-Dashboard showing the text:

Wiki-Dashboard View

Wiki-Dashboard editing the text:

Wiki-Dashboard Edit
Continue Reading »