code-sample

Socket Connection Example for iphone

Hi, I would like to know some sample code to make socket connection from iPhone app and send some date to the lisining port. Thanks, Manish Bahal ...

Hash tables VS associative arrays [PHP]

Recently I have read about hash-tables in a very famous book "Introduction to Algorithms". I haven't used them in any real applications yet, but wanted to. But don't know how to start. Can anyone give me some samples of using it, for example, how to realize dictionary application (like ABBYY Lingvo) using hash-tables? And finally wanted...

Where can I find older versions of the iPhone sample code

I'm trying to find some of the old iphone sample code, becuase it seems like apple will only let you download the most recent versions (compatable with iphone 3.2 +). Is there an archive of these someplace, is there a reason that they remove the older versions of there samepl code? ...

How to compile and build this BHO for IE?

http://www.adp-gmbh.ch/win/com/bho.html When I compile, I get lots of errors: error C2236: unexpected 'class' 'adpbho'. Did you forget a ';'? error C3381: 'adpbho' : assembly access specifiers are only available in code compiled with a /clr option ..\adpbho.cpp(15) : error C3861: 'MB1': identifier not found ..\adpbho.cpp(24) : error C...

C# Samples for Windows Parental Controls API

Can anyone point me to some C# samples for the Windows Parental Controls API. I want to add some functionality that will allow a user to set the duration their child can be logged on in a day. I want to do this as a F/OSS app so that others can benefit from this too. Cheers. ...

How to explain the answer to this java enum question ?

Given public enum Title { MR("Mr."), MRS("Mrs."), MS("Ms."); private final String title; private Title(String t) { title = t; } public String format(String last, String first) { return title + "" + first + "" + last; } } public static void main(String[] args){ System.out.println(Title.MR.format("Doe","John")); } Doe...

Code example, what can I write to impress employer?

I'm not a very creative guy. Often employers ask me to write some code and send it with CV. I know it's mainly to check how my code looks like but I also think that it is important what it is. Do you have any propositions? *This question is related with programming. Imagine that you are a person who check code attached with CV and tell ...

Programming exercise ?

I got this exercise, is not a homework, I just trying to solve: We manage a farm with horses that have to work on the field. A horse has a name, a maximum amount of working hours per week, the amount of hours actually worked and a field to indicate if she is lazy or hard-working. All the attributes ...

Java non-static method addInv(int) cannot be referenced from a static context

I know this error very well however this is the once time I'm stumped. I know that I can't call non-static variables from main method but this is confusing. Maybe you can help? That error is show on addInv(1); line... Code: import java.io.*; import java.util.*; import javax.swing.*; public class item { public static int attack, de...

Singleton in java

I just got to read the following code somewhere : public class SingletonObjectDemo { private static SingletonObjectDemo singletonObject; // Note that the constructor is private private SingletonObjectDemo() { // Optional Code } public static SingletonObjectDemo getSingletonObject() { if (singletonObj...

Java - Deprecated API - DataInputStream.readLine

Time to learn TCP/UDP ... Anyways, my prof gave me this example and he said it worked for him. However when I go to compile I get a deprecated API error saying readLine is not in use anymore... :\ Code: import java.io.*; import java.net.*; public class Server{ static Socket clientSocket = null; static ServerSocket serverSoc...

What is the alternative for System.Data.OracleClient.OracleCommand?

Can anyone share a link to sample (ASP).Net code that uses the new Oracle Data Provider.Net library? I have code a web application code that uses the System.Data.OracleClient classes and want to migrate to the new Oracle Data Provider for .Net. Thanks ...

Old projects are not running in new iPhone SDK 4.0

I have UICatlog project downloaded from apple development library. It was running fine with 3.0 Base SDK, but when I upgrade xCode SDK Version 3.2.3. I am getting en error: error: There is no SDK with the name or path 'iphoneos3.0' Please help. Thanks ...

APIDemos 8 Debug, setting a debug breakpoint at the first line never runs through code in the class

I set a toggle breakpoint at line 36 of the main class, of APIDemos 8, the debug begins at the OnCreate but never processes another line in the class. Why is that? Here's the code starting a line 36. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); ...

APIDemos 8 PersistenceState, where is the persistent text "saved?"

In the class PersistentState.java the prefs variable gets the saved/typed text from prior sessions here, on line 106 into restoredText. Where does the getString method get the saved/typed text? protected void onResume() { super.onResume(); ... SharedPreferences prefs = getPreferences(0); String restoredText = prefs.getStr...

Free iPhone SDK Learning and Game Development Samples

Are there any free iPhone SDK Learning and Game Developement Samples available online? Please mention those URLs. ...

"Cannot find symbol" when testing Java code

I've started writing a class to model a matrix and the compiler gives me this message: Matrix.java:4: cannot find symbol symbol : constructor Matrix(int[][]) location: class Matrix Matrix y = new Matrix(x); This is the code that I was trying to compile: public class Matrix<E> { public static void main(String[] args) { i...

How to optimize this ugly code?

I make the other day a question here, but finally I decided to do it myself for questions of time, now I have a little more time to fix it :D I liked jSoup, but I'm kind of from old school, and preffer doing it my self (thanks to @Bakkal anyway). I manage to made this code, it works fine for now, but if a webpage is not well contructed ...

How to properly delete elements in java arrays

I have a simple program that lets you add, edit, list, search and delete records by storing it on arrays. My problem now, is how to properly delete items on it. Here is my current code. System.out.print("Input number to delete: "); delnum=scanz.nextLine(); intdelnum=Integer.parseInt(delnum); n...

ajax redirect not working

Hello, This is my jsf code :- <h:commandButton id="cmdLogin" value="Login" actionListener="#{indexBean.login}"> <f:ajax execute="@form" render="@all" /> </h:commandButton> This is my login method of indexBean :- public void login(){ HttpServletResponse objHttpSe...