Jump to content

Welcome to Rune Tips, the first ever RuneScape help site. We aim to offer skill guides, quest guides, maps, calculators, informative databases, tips, and much more to help you get the most from the Massive Online Adventure Game, RuneScape, by Jagex Ltd © 2009.

Report Ad

Welcome to Forum.Tip.It
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. If you already have an account, login here - otherwise create an account for free today!

Perakp

Perakp

Member Since 19 Apr 2005
Offline Last Active Aug 22 2012 04:35 AM

Programming puzzles

06 March 2012 - 03:46 PM

Ok I wanted to ask a little fast question, but realized the question was too stupid to ask. Might aswell find the answer myself since I got the pseudocode written. To make the topic worthwhile, post any small programming puzzles or problems to test one's programming abilities.

I'll go first:

In Java I have made my own class, that holds one property. It has a method to set that property and another one to print it to the console.
Consider the following code. What would it print?
Object a = new Object();
a.setProperty(5);
ArrayList<Object> list = new ArrayList<Object>();
list.add(a);

list.get(0).setProperty(6);
a.printProperty();
list.get(0).printProperty();

a.setProperty(4);
a.printProperty();
list.get(0).printProperty();

Answer:

MAMP and PHP

16 February 2012 - 08:55 PM

I downloaded MAMP the other day, which means Apache, MySQL and PHP for Mac. I read that macs have php support installed by default and an apache server built in, so I wonder if I could've just downloaded MySQL...
Anyways, there is this folder called MAMP/htdocs/ where I'm supposed to put my .php files, and then they'd be visible from http://localhost:8888, but so far none of my copy-pasted php hello world's haven't worked. I'm pretty sure my code is flawless, as it's straight from tutorials. Also I managed to run the code using mac's command line, aka terminal, with the command "php helloWorld.php". Been trying to figure out if the problem is with MAMP; did I install it wrong or is there something wrong with the apache server or what. I was hoping this to be more like the "install and you're ready" kind of package they promised it would be.
But if there are any php gurus out there, any words of courage would be appreciated.

A Tale in the Desert

06 December 2011 - 08:24 PM

Official site: http://www.atitd.com/

Wikis:
http://en.wikipedia....e_in_the_Desert
http://www.atitd.org...tale6/Main_Page

In short, A Tale in the Desert is a MMORPG set in ancient Egypt, where players work (*cough*grind*cough*) together to accomplish various tasks and challenges. Every few years they reset the server, this happened last saturday, so if you feel like starting a new MMORPG now would be a good time, or then you can do what I did: just check the game out and leave it at that. You can play the game for free for 24 hours, after which you may continue playing with a 13.95 dollar monthly subscription.
The game has no pvp and no hiscores, so it's very much based on the community of players playing together rather than competing against each other. I played the game for a few hours today, and found it to be worth a recommendation. There's a few camera problems and the command system isn't too intuitive, but I can see why some people would want to spend their money to play this, what I believe to be a truly unique game. As a virtual world and a social experiment, the game is fascinating.


btw I searched for "Games similar to Haven and hearth" and found this. From open pvp permadeath to no pvp at all, but oh well. At least it's a sandbox/dynamic world.

Adventures in c++ [solved for now]

28 October 2011 - 10:53 AM

So I decided to take a course in c++, but making things difficult I want to be able to work at home, which means getting set up on this mac.
Apple has an IDE for cocoa/objective c/c/c++ called xcode which i downloaded, and supposedly it comes with compilers and all. So I should have compilers downloaded. Problem is, I don't get the terminal command g++ working:
-bash: g++: command not found

I want to be able to write code in a text editor and compile and run via command line (aka terminal on osX)

If someone is familiar with setting up compilers, has done c++ programming on a mac system or is feeling otherwise helpful, please share your wits.

Btw I'm posting this here and not on a mac forum because I'm stupid.

EDIT:
Found the location where the compilers are installed. These files are related to the gnu compiler collection:
g++
g++-4.0
g++-4.2
gcc
gcc-4.0
gcc-4.2

The adventure continues!

Java server application

18 October 2011 - 01:29 PM

Hello,

I've written a simple chat application with Java, following easily found tutorials from the internet. I've created a multithreaded serverside to handle multiple connections and a simple but neat chat window.
First I tested the application using getLocalHost() method:
int port=2004;
InetAddress address=InetAddress.getLocalHost();
            requestSocket = new Socket(address, port);
The chat server worked nicely even with multiple chat windows open, each message sent was received by the others etc.
Next, I got the thing working using my internal Ip address, or the ip address given by my router.

Now my problem is, how can I get the thing working from any computer, how do I actually connect two computers through these sockets? So far I've only connected the server to the client on the same computer, but that's of no use unless you enjoy chatting with yourself.

Here's what I've tried and looked into so far:
- router settings. I've told the router to forward outside traffic to my chosen port (2004). The router settings ask for the name of the application. Do I need to put something there or is it just to look nice? What does the router care what application uses the incoming data?
- firewall settings. Now the funny thing is, I'm doing this on a Mac, and there is no way to configure the firewall to open certain ports, it "automagically" opens ports for certain trusted applications (Eclipse included) Turning the firewall off didn't change anything.
- Does it matter that my internet is provided by my university? Is it possible that they have something in place that makes this impossible?


Here are the related parts of my code:
Server side:
 /**
   * Wait for connection attempts and hand out the sockets to threads that manage the connection.
   */
    public void run()
    {
        try{
        serverSocket = new ServerSocket(2004, 10);
        while(running){
            System.out.println("Waiting for connection");
            Socket clientSocket=serverSocket.accept();
            ClientServiceThread [bleep]hread = new ClientServiceThread(clientSocket, id++, this);
            clients[id]=[bleep]hread;
            [bleep]hread.start();
        }
        }catch(Exception e){
            //
        }  
        
    }
Client side:
 /**
     * Connects to the server
     */
    public void connect(){
        try{
            //1. get the socket
            int port=2004
           InetAddress address=InetAddress.getByName(myExternalIpAddress);
            requestSocket = new Socket(address, port);
            //2. get streams
            out = new ObjectOutputStream(requestSocket.getOutputStream());
            out.flush();
            in = new ObjectInputStream(requestSocket.getInputStream());
    }
        catch(Exception e){
           System.out.println("Connection failed");
        }
        }


If you are experience with this kind of thing, please share your knowledge! =)