Dual Boot Menu Location on EEEPC 1005HA

Posted: 27th July 2010 by Andrew Brown in Tutorials
Tags: , ,

Quick post, because, although this is a very simple tip and looked-for constantly, it’s not very documented on the Internet. That is: where is the menu to boot to other devices on the EEEPC 1005HA?

It’s not marked when you boot up. However, you can access it by:

  • Pressing Esc in the very first EEEPC screen when you first power on your netbook

Note that if you press Esc multiple times, the boot screen may not show. Just press it once. Be patient, grasshopper.

Documentation of the Omegle Protocol

Posted: 22nd June 2010 by Andrew Brown in Nonfiction, Tutorials
Tags: ,

Synopsis

Omegle is a website that connects two anonymous strangers together and allows them to have a “no strings attached” conversation. Behind the Omegle uses several PHP pages for its back-end that must be accessed with HTTP POST requests. Each page has a different function, must be passed specific parameters, and returns specific data. All files are located in the root directory and can be accessed at http://www.omegle.com/example-page-name.

The Pages

/start

This page initializes your Omegle session. No parameters need to be passed, but the page should be accessed with a POST request. The page will respond with your six-character Omegle ID encased in quotation marks (“fn8Hkg”). This ID is randomly generated and lasts for the entirety of a conversation. It is composed of the characters a-z, A-Z, 0-9, underscores, and hyphens.

On the server side, accessing this page adds a row in the users table with your Omegle ID and a value indicating that you are not currently in a chat, which allows you to be paired up with someone of similar status. It also affects the count of users online, which is visible on the Omegle homepage.

/count

This page requires no parameters to be passed and can be accessed with a GET or POST request. It returns the current number of users online by counting the current number of rows in the users table. This value can be seen on the Omegle homepage.

/events

Parameter Value
id Your Omegle ID

The events page is constantly accessed by the Omegle front-end to look for updates in the conversation. It must be accessed in a POST request with your Omegle ID set in the id parameter. Connections, disconnections, messages, and notifications are all sent through the events page. The output is formatted as JSON and will need to be parsed as such. An example output is below:
[["waiting"], ["connected"], ["typing"], ["gotMessage", "Welcome to Omegle!"], ["strangerDisconnected"]]

The full list of events that can be passed through this page is as follows:

Event Type Parameter Explanation
waiting Always the first message, this event indicates that your Omegle ID is valid.
connected This event signifies that you have been connected to a stranger.
typing This is a toggle switch; it is shown when the user begins typing and again when they are finished typing. It is automatically toggled off with a gotMessage event.
gotMessage message This event contains messages from the stranger you are chatting with. In addition to relaying their message as a parameter, it also toggles off whether or not they are typing (normally set through the typing event).
strangerDisconnected This event signifies that the stranger you were chatting with has disconnected.

If no new events have occured, the word null is displayed.

/typing

Parameter Value
id Your Omegle ID

Whether or not a user is typing is used as a switch in the Omegle back-end. Accessing this page for the first time toggles your status to on, which means you are typing. Accessing it again toggles your status to off. Both times, an event is sent to whom you are chatting with to signal the change. Note that your typing status automatically switches to off when you access the send page.

/send

Parameter Value
id Your Omegle ID
msg The message to send to your chat partner

The purpose of this page is to allow users to send messages to those they are chatting with. The page must be accessed with a POST request and requires two parameters to be set: id and msg. There is no return value from the server. This page also toggles your typing status to off. The message is written to the msgs table and read later by the /events page.

/disconnect

Parameter Value
id Your Omegle ID

This page disconnects you from your current conversation and alerts the person with whom you were chatting with of the disconnection. It must be accessed with a POST request and passed your Omegle ID as the id parameter. This will remove all rows in the users table matching your Omegle ID.

The Ten Percent Myth

Posted: 14th June 2010 by Andrew Brown in Nonfiction
Tags:

We only use ten percent of our brains.

You’ve heard it time and time again: the myth that humans only use ten percent of their brain, and that if only we could activate “the other 90%,” we’d be much smarter and more successful. Well, it’s wrong.

The brain has no appendix, no unused space. It’s packed tightly into your skull, and every ounce of it is used to its full potential. So where does this ten percent myth come from?

If there’s only one fact you learn about the brain from here, let it be this—the brain has three major areas: sensory areas, motor areas, and association areas.

The sensory areas are the brain’s major center for input. When you look at something, the occipital lobe (the back part of your brain) is fed that raw information from your eyes. When you touch a hot stove, the nerves in your hand send a signal to your brain saying, “Dude, that’s hot!” A scientist can induce an electrical stimulation in this area to make you think you’re touching a hot stove, or seeing something, when you really aren’t.

The motor areas are in charge of your body’s movement. That is, when a signal is sent about halfway up the side of the motor cortex (a strip of brain that runs from ear to ear across the top of your head) your fingers might clench into a fist. Or a stimulus near the bottom of the motor cortex might clench your jaw shut.

And the rest of the brain is made up of association areas. These are the areas that make sense of the information received in the sensory areas. If your hand sends a signal to the brain about what it’s touching, it goes to the sensory cortex, where it is then forwarded on to the correct association area. When the association area makes sense of something, it then stimulates the motor cortex to make the body pull its hand away from a hot stove.

It’s not a coincidence that the association areas occupy 90% of the brain—leaving 10% for the sensory and motor areas—and that the myth says we only use 10% of our brain. Scientists are able to stimulate the motor areas and sensory areas and see results: hearing noises that aren’t there (sensory areas) or the clenching of a jaw (motor areas). However, they can’t do that with association areas; and because of that, scientists thought it had no purpose for the longest time.

We now know for sure with the help of MRIs and fMRIs that humans use 100% of their brain, but the ten percent myth has already been instilled in culture. “Psychics” and other “too-good-to-be-true” phenomenon feed the myth with the recurring theme, “If you only use 10% of your brain now, imagine what you could do if you could use 70%, 80%, or even 100%!” It’s not imperative that the world suddenly know they’re using 100% of their brain, but at least you know now, and you can look smart at your next party.

“We normally use only 10 to 20 percent of our minds. Think how different your life would be if you could utilize that other 80 to 90 percent known as the subconscious mind.” — Craig Karges, Intuitive Edge Program

Observations

  • Random number generators (RNGs) try to simulate real-world randomness.
  • It is impossible for a computer to truly “generate” something random.
  • Flipping a coin ten times and getting a mixture of heads and tails looks more random than getting all heads or all tails.

Question

  • Does an RNG base its generated numbers off of previously-generated numbers to make the results look more random to the human eye?
  • If an RNG isn’t truly random, would it be possible to predict results based off previous results?

Hypothesis

  • If an RNG’s results are based off of previous results to look more random to the human brain, then it is possible to predict future numbers generated from the RNG.

Experiment

I wrote a perl script to simulate ten million consecutive coin flips. After each coin flip, I looked at the result and compared it to the immediate “streak” (defined by how many previous consecutive tails there were if the current result was tails, or how many previous consecutive heads there were if the current result was heads) and tried to predict the next coin flip result.

The formula used to calculate the chance of the streak continuing was: 0.5 ^ (STREAK + 1).

(where STREAK is the number of consecutive, identical results immediately previous).

The code I used is provided here: View Source Code

Results

In the above graph, most results deviate only slightly from the 50% midpoint.

Contrary to my hypothesis, the data seemed exceptionally random and fair in the sense of an equal amount of heads and tails. Additionally, the result of any given coin flip seemed to be independent of any previous flips.

A PDF of the results of five runs is provided here: Download PDF

Conclusion

  • The data does not support my hypothesis that the numbers generated by an RNG are tailored to look more random based off of other generated numbers.

Notes

  • All RNGs are implemented different. While this is the case here, it may not be the case for all RNGs.
  • I used the Perl (v5.10.0 built for i486-linux-gnu-thread-mult) RNG on Ubuntu Linux (2.6.31-20-generic). The RNG used the default seeding method.

RNG Test Study

Posted: 11th June 2010 by Andrew Brown in Nonfiction
Tags:

#!/usr/bin/perl

# This program aims to explore the inherent flaws with a pseudorandom
# generator that is designed to “look” random. In the real world, flipping
# a coin ten times has an equal chance of resulting in ten heads as it does
# some mixture of heads and tails. My hypothesis is that a computer RNG
# actually has less of a chance of ten heads resulting from ten flips as it
# does some combination of heads and tails, due to the purposeful attempts
# to “look” random.

# If my hypothesis is correct, then games and activities that rely on the
# RNG will have predictable results.

use strict;
use warnings;
use constant FLIPS => 10000000;
use constant HEADS => 1;
use constant TAILS => 0;
use constant TRUE => 1;
use constant FALSE => 0;

my ($heads, $tails);
# Results
my ($last, $streak);
# Predictions
my (@predictions);

print “Beginning to flip ” . FLIPS . ” coins…n”;
for (my $i = 0; $i <= FLIPS; $i++)
{
my $flip = int rand() + 0.5; # 0 or 1

if ($flip == HEADS)
{
$heads++;
}
elsif ($flip == TAILS)
{
$tails++;
}

if ($i == 0)
{
$last = $flip;
$streak = 1;
next;
}

# Predict
my $chance_of_streak_continuing = sprintf("%.2f", 0.5 ** ($streak + 1) * 100);

if ($chance_of_streak_continuing < 50.00)
{
# Predicting that the streak will NOT continue
if ($flip == $last)
{
# Streak continued
$predictions[$streak][FALSE]++;
}
else
{
# Streak did NOT continue
$predictions[$streak][TRUE]++;
}
}

# Handle streaks
if ($flip == $last)
{
$streak++;
}
else
{
$streak = 1;
$flip = $last;
}
}

# Print results out
for (my $i = 0; $i < scalar @predictions; $i++)
{
my ($correct, $incorrect, $total);

if ($predictions[$i][TRUE] and $predictions[$i][FALSE])
{
$correct = $predictions[$i][TRUE];
$incorrect = $predictions[$i][FALSE];
$total = $predictions[$i][TRUE] + $predictions[$i][FALSE];

print "After a streak of $i identical results, the next result was ";
print "able to be predicted ";
print sprintf("%.2f", $correct / $total * 100);
print "% of the time.n";
}
}

Adding More Regions to a Theme in Drupal 6

Posted: 14th May 2010 by Andrew Brown in Tutorials
Tags:

I installed a new theme on the site today and wasn’t satisfied with the regions offered for placing blocks. Luckily, I’m a brilliant hacker of code and knew how to add more. And I promise to you, in less than 5 minutes, you’ll know how to add new regions to a Drupal 6 theme too!

In each theme, you’ll have a .info file and a page.tpl.php file. You have others, but these are the important ones for adding regions. Assuming you have a theme named Awesome, your files would be Awesome.info and page.tpl.php.

Awesome.info is pretty straight-forward to edit.
regions[left] = Left sidebar (on right)
regions[right] = Right sidebar (on right)
regions[footer_left] = Footer left
regions[footer_right] = Footer right
regions[footer] = Footer bottom

To add a region called aftercontent, simply add the following line:
regions[aftercontent] = After content

In page.tpl.php, add the following snippit (replacing aftercontent with the name of your region, if need be) where you want the region to be:

<?php if ($aftercontent): ?>
<div id="aftercontent" class="region">
<?php print $aftercontent; ?>
</div>
<?php endif; ?>

Once you’ve done that, there’s one last step. You’ll need to go to admin/settings/performance and clear the site cache to make the region appear in the blocks menu.

Congrats, now you know how to add regions for blocks on Drupal 6! :)

Drupal 6: Making clean URLs work with 000webhost

Posted: 27th April 2010 by Andrew Brown in Tutorials
Tags: , ,

I’ve seen a ton of people having trouble getting Drupal to emit clean URLs with their installation and the answer isn’t always the same due to the myriad of different hosting providers and servers out there.

My hosting provider of choice is 000webhost but until today I haven’t figured out how to successfully use clean URLs.

The fix is actually quite simple: they add some analytics code to your site automatically so you can view access statistics and whatnot from your control panel, but it actually messes up clean URLs. I’m not quite sure why.

In any case, here’s the fix:

  1. Uncomment (or add) the following line in your .htaccess file:
    RewriteBase /
    *Note that if your Drupal installation is in a folder, / should be the name of that folder—like /drupal.
  2. Deactivate the analytics code
  3. Enable clean URLs on your site!

That’s it! Have a question? Leave it in the comments below.

Imagine you’re standing in your dusty garage. It’s completely empty aside from you and ten cardboard boxes lined up in a row on the concrete floor in front of you. In each of these boxes are your personal documents, organized in chronological order. The boxes are closed, so how do you know what is in each box?

You look closer at the sides of the boxes and notice that each one is numbered: 1, 2, 3, 4, 5, and so on. “Okay,” you think aloud, “but where is the TPS report I’m supposed to have? Lumberg needs it by this afternoon.”

You could start at the beginning of the boxes and look through them for the document you’re looking for, but that would take far too long. Instead, you remember that you are holding a clipboard. On that clipboard is a piece of paper, and on that piece of paper is a list of every document in the boxes. You slide your finger down the list, looking for “TPS report” and see that it is the third document in Box 6.

Computers store their files in a very similar way. Every bit (bits are what your files are made of at the lowest level) has its own address it can be found at on the hard drive. When a user wants to open a file, for example TPSReport.txt, the computer looks up on its own metaphorical clipboard where the file is located (just like how you did on your own clipboard ten seconds ago) and basically jumps directly to that place in memory to load the file. So when you double click TPSReport.txt on your desktop, the computer opens up notepad and loads in whatever is stored in the hard drive’s equivalent to Box 6: Document 3.

However, there are actions on the user’s end that don’t penetrate deep into the computer’s inner workings. One of these actions is deleting files. Your computer has a clipboard of where every file is, just like you did in your garage. When you move something to the recycle bin on Windows, it removes the entry on the clipboard that says “Desktop/TPSReport.txt is the third document in Box 6″ and adds another row at the bottom saying something like, “Recycle Bin/TPSReport.txt is the third document in Box 6.” This way, people can recover documents from their recycle bin that they didn’t mean to delete.

But any avid Windows user knows that holding down shift and pressing delete on a file brings up a dialog box asking if you’re sure you want to “permanently delete” that file. If you click OK, the file poofs — never to be seen again.

That is, unless someone looks for it.

Computers (and Windows in particular, when it says it is permanently deleting a file) are a bit misleading. When you “delete” a file, what is actually happening is this: the computer removes the row on the clipboard that says where that file is stored. If an icon stayed on your desktop somehow and you double-clicked it, the computer wouldn’t have a row that says where the file is, so it couldn’t open it.

So for the most part it is “deleted.” You can’t open it, and someone getting on your computer can’t open it.

Except the file is still in Box 6. In fact, it’s still the third document in Box 6. There’s just no row on your clipboard to tell you that. If you knew–maybe from your brilliant memory of a minute ago–you could go back and grab it directly out of the box, as long as you knew where to look for it. The same goes with computers.

Lets not forget the original option that you thought about doing when you wanted to find the file. You could have started at the first box, ignoring your clipboard, and looked through each box until you found the one you were looking for. It’d be slow, but you’d be guaranteed to find it if it were stored in one of the boxes.

The same concept applies here, and that’s how a lot of our new-age computer forensics tools work. When the government, police, or even just a hobby techie, gets ahold of your computer, a simple tool can retrieve all of your files–even the ones you’ve deleted. This type of tool catches hackers, pedophiles, warez distributors, and basically anyone suspected of unlawful activity on a computer.

Now, you may be asking: so how do I actually delete my files?

The truth is, unless you’re paranoid enough to want them deleted immediately, they will delete themselves over time. As you create more files, edit old files, use programs, or even turn on your computer, more space is needed by the computer to save stuff. When a computer needs more space to store stuff, it looks at its clipboard and finds space that isn’t currently being used. It’s basically random whether it picks a space that is where your “deleted” file is hiding, or whether it picks other spaces. To truly delete your files, you just need your computer to write over them with new data. So basically, your computer has to take out documents in Box 6 to make room for new documents (they’re placed in the same place, but they’re different. Once they’re out of the box, they’re gone for good in the computer’s eyes. After all, the computer wouldn’t look at the rest of your garage, it’d only look at what is inside the boxes.)

If you’re extremely paranoid or working in a setting where you need to make sure your files aren’t recoverable, the Department of Defense has created the DoD 5220.22-M standard for ensuring complete erasure of a file. It states that writing over a file 35 times with specific values (zeros the first time, ones the second time, random digits the third time, and so on) will render a file (or a whole hard drive, depending on what you’re trying to do) completely unrecoverable by any means. The popular program, Derik’s Book & Nuke (DBAN) automates this process.

In conclusion, “deleting” a file doesn’t actually delete it. Instead, it solely makes the computer forget where it is stored in memory and allows the space to be used for other files or purposes. Until the space has been overwritten, the file is completely recoverable with the right tools and a sexy geek behind the keyboard.

When someone first starts programming, the whole concept of “interpreted” languages and “compiled” languages might seem a bit confusing. Luckily, you have someone super smart like me to explain them to you in a manner that even your great grandpa could understand — even if he’s dead!

All decent programming languages are either compiled or interpreted. What language you’re programming in determines whether you need to download an interpreter or a compiler to run the programs you create. There are a few differences between the two types of languages.

A “compiled” program is just that: compiled. Everything that has to do with the program, including the source code, required files, references, and anything else, is all rolled up into one “standalone” executable that can run on any similar system without needing to install anything else. Any program that you download from the internet and are able to “just run” is a standalone executable that has been compiled.

With an interpreted language, you need an interpreter to run the program. You feed the source code to the interpreter as it runs and it creates the program on the fly. Because of this, interpreted languages are traditionally slower than compiled languages, but not usually enough to notice for general programming. If you’re relying on calculation-heavy processing, however, you’ll probably want to go with a faster, compiled language.

C and C++ are common compiled languages. When you compile a C++ program, for example, you receive an executable, or binary file, that you can run on any system that shares an operating system with the one that compiled the program. For example, if you compiled the program on Windows 7, you’ll generally be able to run it on any other Windows 7, Windows Vista, or Windows XP computer. If you want to run it on another operating system such as a Mac, you’ll have to compile the source code on a Mac to get a Mac binary file.

Conversely, interpreted languages such as Perl and PHP may require an interpreter installed, but the same source code can be fed into an interpreter on any operating system without modifications (unless you’re a bad programmer and use OS-specific system calls). This allows you to write a program on Windows, for example, and quickly distribute it to other Windows users, Mac users, Linux users, even people who installed BSD on their roommate’s microwave.

Occasionally you’ll stumble upon a weird language that makes up its own rules, such as Java. They allow you to “compile” your program, but people who want to run it still need to install what amounts to be a Java interpreter—the Java Virtual Machine (JVM).

In conclusion, programming languages can be split into two types: interpreted and compiled. If you’re looking to hide your source code, distribute to computers that don’t need to install an interpreter, or need a faster executable, you probably want a compiled language. If you’re looking to whip up quick scripts that can be run on any operating system (installing an interpreter is a one-time thing, and most non-Windows systems come with several interpreters already installed!), want to ensure that your programs are safe, or are just looking for a traditionally easier language to program in, you might be interested in an interpreted language.

Thing a Week 5: True Story

Posted: 3rd February 2010 by Andrew Brown in Nonfiction, Thing-A-Week
Tags: ,

There was a college philosophy class that students always tried to get into because of how cool they heard the professor was. They said he gave open-ended writing assignments and provided ample time for debate and discussions in the classroom. Although he was lenient in the classroom, he always made sure the students learned by his dreadfully hard tests. His system worked well; students heard about how hard the tests were, so they tried extra hard to learn the material they needed to pass.

One semester, the professor hinted almost every other day at a new final exam that he was coming up with that was supposed to be extraordinarily complex. Although he said it would be the hardest exam the students had ever taken, he promised they would have no trouble with it if they paid attention when he preached philosophy from his professor pedestal.

When the final exam finally rolled around, every student that had been in the classroom on the first day returned to their seat on the last day. The professor had a sizable stack of papers on top of his pedestal, and waited until everyone had arrived to begin handing them out.

Each student got a paper-clipped packet of ten pages of paper. On the first page there was one question, and the rest of the space was provided to write in. There wasn’t a single student that wasn’t surprised at the question, and some actually looked angry, scanning through the rest of the pages for the key to this silly trick.

The one question on the test was: “Why?”

Several minutes later, when the students began to understand that the test wasn’t a joke, the sound of graphite scraping against paper filled the otherwise quiet room. Within five minutes of the test being handed out, one student stood and proudly handed his test to his professor before leaving the room.

As a courtesy to the other students, the professor neatly placed the test face-down on his desk to silently notify the students where to place their tests when they were done. The professor sat down in his chair, curious how the student finished his test so quickly.

That night, the professor came upon the test that had relentlessly teased his mind earlier. He looked down at the student’s answer: “Why not?”

The professor was in awe of the answer and promptly marked an A at the top of the exam and moved on to the next one.