When I first got the iPhone, they used to tell me that the only means to get an internet connection to the iPhone is either the 3G or through a Wi-Fi access-point. I used to connect my older iMate to the internet over its USB connection to the laptop, that’s not possible anymore with the iPhone.
To keep it short, here’s what you need to do …
First, we need to create an ad hoc network. The iPhone needs to connect to a Wi-Fi access-point. It’s not possible to connect it directly to your laptop. So, we’ll create an ad hoc wireless network on the laptop, were other laptops and devices can connect to just as connecting to an access-point.
(The next steps are performed on Windows Vista. For Windows XP, do this and jump to step X.)
- Make sure your wireless adapter is enabled.
- Open the Networks and Sharing Center. Under Tasks (left), choose Manage Wireless Networks.
- In the Manage Wireless Networks window, click Add.
- Choose “Create an ad hoc network”. Press Next on the next page.
- On the next page, enter a Network Name of your choice (as “iPhoneNetwork”). This is the network you’ll connect to from your iPhone. Choose WEP for Security Type (you can also choose “No Authentication (Open)”, but this way anyone in your ad hoc wireless network range can connect to your laptop.) Enter a Security Key as instructed, check “Save this network” and click Next.
- You should get the “Your iPhoneNetwork is ready to use”. Before pressing Close, click on “Turn on Internet Connection sharing”.
- Select your Local Area Network internet connection you usually use to connect to the internet and press Next. The next page should say “Internet connection sharing is enabled.” Press Close.
Now, your ad hoc network is ready.
The second step is connecting your iPhone to the “iPhoneNetwork” ad hoc wireless network.
- From your iPhone, open Settings. Choose Wi-Fi.

- Click on “iPhoneNetwork” and enter the password you defined earlier (Security Key), then press Join. It take you back to the previous screen but with the “iPhoneNetwork” checked.
- On your laptop, you should see the “Set Network Location” screen. Choose Home or Work, no big deal.
You should open Safari browser and connect directly to the internet. Connect to Google or something to make sure that everything’s fine. And, yes, it’s a little buggy – you’ll sometimes have to do it over and over again!
Now you can access iTunes store or even download/update your iPhone applications directly without needing to do that on iTunes. Enjoy

that was one of the assignments in Scientific Computing Dept in my college
“to construct a simple polygon form ALL the points i have in a plan”
well, a simple polygon is the polygon where it’s edges doesn’t intersect

i thought of an algorithm that is near to the incremental convex hull algorithm
and here is the pseudo-code
Simple_Polygon_Construction (Points)
Sort (Points) //sort the points Ascending on x and descending on Y
Line L=Construct_Line(Points[0],Points[Points->Size]) //construct a line from the two extreme points on the X-Axis
ForEach Point p in Points
IF p above L
Add p to Polygon toReturn
Else
Add p to tempStack
End ForEach
While !tempStack->Empty()
Add tempStack->top() to Polygon toReturn
tempStack->pop()
End While
return Polygon toReturn
well the algorithm weight here will be O(n log (n) ) as it will be the sorting complexity and the polygon construction will be O(n)
where n is the number of points
till now i’ve tested it on 100 random points and it worked fine
i think the only case that the algorithm won’t work as expected is when ALL the points are colinear where a simple polygon is not possible
i searched for any other algos and didn’t find any, i duno why
thats why i posted this topic
if u have any comment pliz be my guest

Alsalam alikom wa ra7mat Allah wa barakatoh (Peace upon you)
![]()
Have you ever got the feeling that you are sitting inside a hedge… in the sense that you are surrounded by noon-sun light but you don’t know the directions… and despite the fact that you are a few inches away from both sides, you are afraid to go either ways because you don’t know which side leads to the sharp edge and which is the safe ground…
What would you do… either wait the sun to set or take your best bet…
I don’t think there is a right answer, if there is one it would be “it depends”…
At least for me, I still can’t figure out what does it depend on! and I’m afraid to death that I won’t know till sunset! …
If I can ask you for one thing, that will be your prayers…
Alsalam alikom wa ra7mat Allah wa barakatoh
Ever dreamed of having the Sixth Sense?
If you haven’t seen this video yet, here’s it …
(Here’s the original post at TED’s, and here’s a download link if you prefer downloading it to your desktop as I do.)
So, now you see birds flying around your head and you go like, DUH?! loool
I’m sure you’ll be able to test it soon, coz they’ll get tons of exclusive business deals to bring it to the market ASAP – of course, you can test it, at a ten-times-at-least of the original price. Business sells stuff anyway, regardless how beneficial they are at the long run …
Well, even though it’s a marvelous breakthrough in the field of Human-Computer Interaction, you should really read the posted comments below the video on the TED Website …
I would really like to know what you people think about it??
Let me see your comment …
PS: Seen the tag-cloud and that folk’s t-shirt?! You’d better watch what you post on the internet about you starting from now … loool

The Microsoft Web Platform Installer 2.0 (Web PI) is a free tool that makes it simple to download, install and keep up-to-date with the latest components of the Microsoft Web Platform, including Internet Information Services (IIS), SQL Server Express, .NET Framework and Visual Web Developer. In addition, install popular open source ASP.NET and PHP web apps with the Web PI.
Here is the code snippet if you want to spread the word :)
<a href="http://go.microsoft.com/fwlink/?LinkId=146503" title="Get the Microsoft Web Platform">
<img src="http://www.microsoft.com/web/media/badge/get_microsoft_web_platform.png" alt="Get the Microsoft Web Platform" border="0" />
</a>
Now, you want to type some text in Arabic, let’s say a one-page letter .. No, half-a-page letter .. Let’s even say a single paragraph, OK? How long does it take you to just find where the next letter is?!!!
No matter how much I train myself to the Arabic keyboard layout – it’s never like the English! I’m typing in every letter in this post without even looking at the keyboard, wouldn’t you just dream to do the same with Arabic text?
Instead, we all go for what we call, Franco Arabic, which is more like the native Arabic syntax in the technology world. Time goes by and we ended up with a generation that doesn’t know how to spell yasta6ee3 and yadtar (يستطيع ويضطر) without mixing up the letters ت, ط and ض ..
One of the most innovative solutions, was the Yamli approach:

Yamli is simply a search engine, that allows the user to type in Arabic text to search for without having an Arabic Keyboard – they call that the “Smart Arabic Keyboard”. The idea was originated by the end of 2007, when a couple of folks needed to search Google and were stuck as the laptop didn’t have an Arabic keyboard.
It doesn’t end at the Arabic search. Check out the Yamli Editor, a simple web-based editor with their Smart Arabic Keyboard – Just type in your text, then copy-paste it anywhere you wish. You could even incorporate their Smart Keyboard into your website, or add their Facebook Application to help you in your comments, wall-to-wall posts and messages.
So, where’s the catch? I’ll tell you – it’s all online!
Let’s say you want a similar service, locally on your PC or Laptop? I suggest you try 3arabik.
![]()
3arabik is a keyboard layout, that maps your English letters to Arabic ones; so you just press the keys in English, and it will type in the Arabic letter for it – just like Franco Arabic. Meaning ا is “A”, ب is “B”, ت is “T” and so on ..
Just to imagine, let’s say you want to type my last name for instance, “Shaker”, you need to press “s” and it will type س, “h” transforming it to ش, then “a”, “k” and “r” for ا, ك and ر – giving you شاكر.
It’s for free. The website has the installation instructions, and the keyboard mappings (if you don’t get it by intuition already). A friend of mine just sent me the link last week. It’s great honestly, but I’m till not used to it yet coz my Franco Arab is perfect as in reflecting correct pronunciation. So I always write “Shaker” wrong coz I press “e” by mistake. However, you’ll get used to it sooner or later ..
I also loved their Flash loader .. loool
– Top Image: from the ilovetypography blog
Posted in Technology Tagged: Arabic, Hacks, Text
It really is, LOL. This isn’t an important post, don’t proceed …
You just don’t listen, do you?
It’s been a long time since I last blogged, and even the last post was later than its content. Even the Problem-of-the-week thing, didn’t even keep us of-the-month!
Blogging needs a “mood”, and that’s –unfortunately- not that available anymore as much as before, due to the seems-to-become-daily time-squeeze I’m suffering right now …
I’ve changed the blog theme as well; I liked the old, black one more – it was elegant. This one’s nice too, I hope it’s more readable. I like the new Windows Live Writer by the way, in case you’re interested …
Let’s hope I try to keep it up some time. A few posts are coming up next as a come back .. ta-ta-ta-taaa!
Posted in Personal Tagged: Blogging
Motivation
A singly linked list is a common data structure familiar to all computer scientists. A singly linked list is made of nodes where each node has a pointer to the next node (or NULL to end the list). A singly linked list is often used as a stack (or last-in-first-out queue (LIFO)) because adding a new fist element, removing the existing first element, and examining the first element are very fast O(1) operations.
When working with singly linked lists, you are typically given a link to the first node. Common operations on a singly linked list are iterating through all the nodes, adding to the list, or deleting from the list. Algorithms for these operations generally require a well formed linked list. That is, a linked list without loops or cycles in it.
If a linked list has a cycle:
- The malformed linked list has no end (no node ever has a NULL next_node pointer)
- The malformed linked list contains two links to some node
- Iterating through the malformed linked list will yield all nodes in the loop multiple times
A malformed linked list with a loop causes iteration over the list to fail because the iteration will never reach the end of the list. Therefore, it is desirable to be able to detect that a linked list is malformed before trying iteration. This article is a discussion of various algorithms to detect a loop in a singly linked list.
Data Structure
struct Node
{
private:
Node *_next, *_prev;
bool _seen; // Only needed in one solution.
public:
bool getSeen() // Only needed in one solution.
{
return _seen;
}
void setSeen(bool seen) // Only needed in one solution.
{
_seen = seen;
}
Node* getNext()
{
return _next;
}
void setNext(Node* next)
{
_next = next;
}
Node* getPrev()
{
return _prev;
}
void setPrev(Node* prev)
{
_prev = prev;
}
};
Incorrect "Solutions"
Traverse the List until the End
Just look at the entire list to see if it has an end. When it ends, return.
// Incorrect 'solution'
bool hasLoop(Node* startNode)
{
Node* currentNode = startNode;
while (currentNode = currentNode->getNext());
return false;
}
The problem with this solution is that if the linked list does have a loop, the program will never terminate. There is no way for this algorithm to return true when the linked list does have a loop.
Mark Each Node
Traverse the list and mark each node as having been seen. If you come to a node that has already been marked, then you know that the list has a loop.
// Incorrect 'solution'
bool hasLoop(Node* startNode)
{
Node* currentNode = startNode;
do {
if (currentNode->getSeen())
return true;
currentNode->setSeen(true);
} while (currentNode = currentNode->getNext());
return false;
}
The problem with this solution is ensuring that _seen is marked as false for all the nodes before you start. If the linked list has a loop, it isn't possible to iterate over each node to set _seen to false as an initial value for each node. It might be possible to overcome some of this by using an int rather than a bool and using a random integer as your marker. In that case there is a good chance that no node will have your initial value, but a small chance that one would and your algorithm would fail.
Even if you are able to solve the initial value problem, each node in a linked list may not have a field to use for this purpose. Requiring such a field in each node would mean that this is not a generic solution. As we will see later, this field is not needed for a perfectly correct and efficient solution anyway.
Detect Only Full Loops
When asked to come up with a solution, a common pitfall is not detecting all loops, but just a loop where the last node links to the first. A loop could still occur (and not be detected) if the last element linked to (for example) the second element.
// Incorrect 'solution'
bool hasLoop(Node* startNode)
{
Node* currentNode = startNode;
while (currentNode = currentNode->getNext())
if (currentNode == startNode)
return true;
return false;
Inefficient Solutions
Keep a Hash-Set of All Nodes Seen So Far
[O(n) Time Complexity]
[O(n) Space Complexity]
Keeping a set of all the nodes that have been seen so far and testing to see if the next node is in that set would be a perfectly correct solution. It would run fast as well. However it would use enough extra space to make a copy of the linked list. Allocating such much memory is prohibitively expensive for large lists.
// Inefficient solution
bool hasLoop(Node* startNode)
{
map bool > nodesSeen;
Node* currentNode = startNode;
do {
if (nodesSeen.find(currentNode) != nodesSeen.end()) // Node Found
return true;
nodesSeen.insert(pairbool>(currentNode, true));
} while (currentNode = currentNode->getNext());
return false;
Use a Doubly-Linked List
[O(n) Time Complexity]
Doubly linked lists make it easy to tell if there is a loop. If you encounter any node that doesn't link to the last node you visited, you know that there are two nodes linking to that node. Because the back links could be initially messed up in some other way, this algorithm is only correct if you can trust the back links. Otherwise it is just a malformed doubly linked list finder. The singly linked list can even be converted into a doubly linked list with little additional work. Again this will require that we change the structure of the Node to accommodate a second link (something that may not be possible in all cases). Usually a singly linked list is used because the amount of space to allocate for each node is at a premium.
// Inefficient solution
bool hasLoop(Node* startNode)
{
Node* currentNode = startNode;
Node* previousNode = NULL;
do {
if (previousNode && currentNode->getPrev() && previousNode != currentNode->getPrev())
return true;
if (!currentNode->getPrev())
currentNode->setPrev(previousNode);
previousNode = currentNode;
} while (currentNode = currentNode->getNext());
return false;
}
Check the Entire List So Far
[O(n^2) Time Complexity]
For each node, assume that the portion of the list examined so for has no loops and check to see if the next node creates a loop by iterating again over the entire list up to that point.
// Inefficient solution
bool hasLoop(Node* startNode){
Node* currentNode = startNode->getNext();
int i = 0;
do {
Node* checkNode = startNode;
int j = 0;
do {
if (checkNode == currentNode)
return true;
j++;
} while ((i getNext()));
i++;
} while (currentNode = currentNode->getNext());
return false;
}
Reverse the list
O(n) time complexity
If you reverse the list, and remember the initial node, you will know that there is a cycle if you get back to the first node. While efficient, this solution changes the list. Reversing the list twice would put the list back in its initial state; however this solution is not appropriate for multi-threaded applications. In some cases there may not be a way to modify nodes. Since changing the nodes is not needed to get the answer, this solution is not recommended.
// Solution modifies the list
bool hasLoop(Node* startNode)
{
Node *previousNode = NULL, *currentNode = startNode, *nextNode;
if (!currentNode->getNext())
return false;
while (currentNode)
{
nextNode = currentNode->getNext();
currentNode->setNext(previousNode);
previousNode = currentNode;
currentNode = nextNode;
}
return (previousNode == startNode);
}
Credit for this solution goes to Piyush Srivastava.
Use Memory Allocation Information
O(n) time complexity in the amount of memory on the computer
Some programming languages allow you to see meta-information about each node: the memory address at which it is allocated, for example. Because each node has a unique numeric address, it is possible to use this information to detect cycles. For this algorithm, keep track of the minimum memory address seen, the maximum memory address seen, and the number of nodes seen. If more nodes have been seen than can fit in the address space then some node must have been seen twice and there is a cycle.
// Depends on the size of the available computer memory rather than the size of the list.
bool hasLoop(Node* startNode)
{
Node *currentNode = startNode, *minAddress = currentNode, *maxAddress = currentNode;
int nodesSeen = 0;
while(currentNode = currentNode->getNext()){
nodesSeen++;
if (currentNode
minAddress = currentNode;
if (currentNode > maxAddress)
maxAddress = currentNode;
if (maxAddress - minAddress > nodesSeen)
return true;
}
return false;
}
This algorithm relies on being able to see memory address information. This is not possible to implement in some programming languages such as Java that do not make this information available. It is likely that the entire list will be allocated close together in memory. In such a case the implementation will run close to the running time of the length of the list. However, if the nodes in the list are allocated over a large memory space, the runtime of this algorithm could be much greater than some of the best solutions.
Best Solutions
Catch Larger and Larger Loops
[O(n) Time Complexity]
Always store some node to check. Occasionally reset this node to avoid the "Detect Only Full Loops" problem. When resetting it, double the amount of time before resetting it again.
// Good solution
bool hasLoop(Node* startNode)
{
Node *currentNode = startNode, *checkNode = NULL;
int since = 0, sinceScale = 2;
do {
if (checkNode == currentNode)
return true;
if (since >= sinceScale)
{
checkNode = currentNode;
since = 0;
sinceScale = sinceScale * 2;
}
since++;
} while (currentNode = currentNode->getNext());
return false;
}
This solution is O(n) because sinceScale grows linearly with the number of calls to getNext(). Once sinceScale is greater than the size of the loop, another n calls to getNext() may be required to detect the loop. This solution requires up to 3 traversals of the list.
This solution was devised by Stephen Ostermiller and proven O(n) by Daniel Martin.
Catch Loops in Two Passes
[O(n) Time Complexity]
Simultaneously go through the list by ones (slow iterator) and by twos (fast iterator). If there is a loop the fast iterator will go around that loop twice as fast as the slow iterator. The fast iterator will lap the slow iterator within a single pass through the cycle. Detecting a loop is then just detecting that the slow iterator has been lapped by the fast iterator.
// Best solution
bool hasLoop(Node* startNode)
{
Node *slowNode = startNode, *fastNode1 = startNode, *fastNode2 = startNode;
while (slowNode && (fastNode1 = fastNode2->getNext()) && (fastNode2 = fastNode1->getNext()))
{
if (slowNode == fastNode1 || slowNode == fastNode2)
return true;
slowNode = slowNode->getNext();
}
return false;
}
This solution is "Floyd's Cycle-Finding Algorithm" as published in "Non-Deterministic Algorithms" by Robert W. Floyd in 1967. It is also called "The Tortoise and the Hare Algorithm".
Adopted from this page with recoding in C++.
This is the pdf version of this article.
Check out this URL: http://weblogs.asp.net/scottgu/archive/2009/03/10/free-asp-net-mvc-ebook-tutorial.aspx
Its a free ASP.NET MVC book by Scott Gu :)
"I wrote the first chapter of the book - which is a 185 page end-to-end tutorial that walks-through building a small, but complete, ASP.NET MVC application from scratch. The agreement I made with Wrox was that I'd write it for free in return for them also making it available as a free PDF download."... Scott Gu
Enjoy ;)
There’s a “category” of questions that is commonly asked in large companies’ interviews that tests your thorough understanding of a certain programming language. I’ll send you an episode each time I remember one of them…
Represent x ? y : z as function int ternary(int x, int y, int z); using only ~, !, ^, &, +, |, << and >>. You’re not allowed to use -, * or if-else.
Solution 1:
int ternary(int x, int y, int z)
{
int ret[2] = {y, z};
return ret[!x];
}
The only comment here is that if x is 0, !x is 1… and if x is NOT 0, which means true in C++ as you probably know; !x is 0 – which is exactly what we want to index the array properly.
Solution 2:
int ternary(int x, int y, int z)
{
int t;
(!x && (t = z)) || (x && (t = y));
return t;
}
This one is actually important. Remember that the expression t = z (or t = y) evaluates to z (or y), and in the same time loads in t the correct value. That’s why we can depend on t in the end.
Thanks to F.M.A.R. who sent me this problem...
This is the pdf version of this article.