You are currently browsing the monthly archive for August, 2008.

Right, so I am actually working on something. I will not tell you what I am working on, but it is a website, if it is not that obvious. Powered by PHP, a language I was ranting about (I was ranting to myself) for about an hour before quiting and heading to my living room to watch Family Guy.

It went like this: have you ever, doesn’t matter which language, made major and enormous modifications to the source since the last time you actually ran it? I do that a lot. When I’m writing Python, it’s not a big deal because not only does it have a wonderful exception system, but I’m always happy no matter the situation as long as I’m working with Python. Why is that? I love Python. It’s the greatest language that I’ve ever worked with, even if I did nothing but a bunch of file management. What happens when I modify a large portion of the source code and the language is PHP? That’s an entirely different story.

Let me bring you up to speed: in the first stages of my works, I’m always sloppy: files are everywhere, very few folders and hardly any organization. In fact, I would usually have around 7 files all doing different things and only the root folder to hold them in (unless it’s Python – I’m super organized with that). Mind you, they each have at least 4kb of data and this is usually the first hour in. As you can guess, as the days pass, things get beyond manageable unless I was to write everything I do onto a piece of paper. My mind isn’t concentrating on what I’m doing, but more so where I put what where. My mind and source become a pile of yucky spaghetti. Spaghetti that’s yucky. I like spaghetti.

So, after I decide that I’m ready, the self-proclaimed Age of Organization and Mass Tank Production begins. I begin classifying the files into folders, all based on what they do. I then create the core file that determines what is loaded and when. The last time I did this, I had a total of 9 folders and 16 files, not including the mySQL files and self-proclaimed prototypes. Not much, I know. Start small, end big?

Moving along. The only way I can upload all these folders and files in 10 seconds is through a zip file (also known as a compressed file). So, I do that. I upload and then extract. This is when the strange events start happening. In my source, I have a form and a bunch of functions that allow the user (you) to upload images and a bunch of other cool-but-unfinished-shit. Let me explain a little more: the result is either 3 images or 2 images. 1 image is the one that the user (you) uploaded, and another is a thumbnail (resized copy, usually very small compared to the real thing) of that image. The third is another resized, but only if the original is too large (who resizes images through XHTML/HTML, huh?).

The strange thing is, that third image always came out crappy. After many hypothesis, I had determined that the script was either resizing the image to be smaller and then making it bigger, or it was copying the thumbnail and then making it bigger. I spent up towards to one hour trying to figure out the problem. I then concluded that PHP was either retarded, poorly coded, or that the world is going insane. This is the part where I go and watch Family Guy.

After I returned, I tied to solve the mystery of the fucking-image-that-turned-into-a-pile-of-resized-crap. For some reason, I went into the index file (the file whose name is index) and discovered something shocking: the require were pointing to an old variant of the file that handles the image uploads! In other words, I thought the problem was in the newer variant when in reality it wasn’t even being used! The moral of the story is basically this: ALWAYS, ALWAYS, delete every single file and folder in the directory that you’re uploading your zip to. OR, double check everything in the file before uploading it!

Edward Current is hilarious. Watch:

I also find it amazing how he can play all those instruments. Great job, man!

Fuck.

There’s a large difference between the two. Most not familiar with either of the terms usually assume that both are one the same. If you were to call me a wap, then that is a great insult. It’s like telling me to go fuck my mother, which I will never do for as long as I am able to.

Otaku

  1. I like anime, manga, or video games.
  2. I don’t care whether someone is Japanese or not.
  3. I knew how to use chopsticks before I watched anything Japanese.
  4. I know that chopsticks are actually Chinese and not Japanese.
  5. I know that almost everything in Japan was invented in another country.
  6. I don’t do cosplay, but I know what cosplay is and what it is not.
  7. I do do cosplay and I hate posers/fakes. Great insult!
  8. I like all kinds of music.
  9. I know when to use “costume” and when to use “cosplay.”
  10. I get insulted when someone calls me a wap or Japan-o-phile.
  11. I’ve taken a class on Japanese history/culture (or had a unit of Japanese history/culture in class).
  12. I know something about the history of the “otaku.”
  13. I didn’t learn everything I know about the otaku subculture from Genshiken or a similar series/story.
  14. I have a blog and/or read a blog something in the past year.
  15. I spend what money I have on manga, anime, video games or models (models don’t have to be Japanese-oriented).
  16. I go to conventions with friends and not an intention to make them (naturally making friends is fine; planning to make friends is something else).
  17. If I like an anime or video game, I get the theme songs and/or any soundtracks (if illegally, shame on you).
  18. I want to move to Japan for Akiba or to just see the sights (as long as you research something about the nation, then that’s accountable as well).
  19. I know that Japan is a country just like America or United Kingdom and that they just make a better and more productive use of technology.
  20. Naruto is a good anime, but not nearly the best (Suzumiya Haruhi no yuutsu is the best!!)
  21. I hate the majority of anime or manga oriented message boards.
  22. I hate any anime series that is over 100 episodes (you can choose your exception. As in, with the exception of Bleach, I agree).
  23. My favorite genre(s) exceed (is not, not limited to) seinen.
  24. I have an interest in one of the following genres: romance, love comedies, ecchi, yuri, magical girls and/or yaoi or similar series.

Wapanese

  1. Naruto is the best anime ever.
  2. I have a Naruto headband that I wear everyday (every other day does not count).
  3. I like typing “kawaii” instead of “cute.”
  4. I like using half-breed sentences: Japanese and English in one sentence.
  5. I love Japanese people.
  6. I prefer chopsticks over forks.
  7. Ramen is the best food in the world and always will be!
  8. Genshiken is the encyclopedia of the otaku culture!
  9. I wish I could speak Japanese!!
  10. I wish I was Japanese.
  11. Japanese rock is way better than American rock (personal note: no it is not!)!
  12. English is the stupidest language ever!!
  13. I don’t know what Hiragana or Katakana is.
  14. I would like to learn Japanese, I just don’t know how (sarcastically declaring one’s own innocence)!
  15. I frequent on 4chan or similar images boards.
  16. The stuff at 4chan is hilarious!
  17. I try and meet Japanese people on a social network (unless you’re trying to interview, research or to improve your Japanese).
  18. I’m not in a Japanese club.
  19. I know how to speak/write in Engrish, even though I’m a native speaker (English was your first language).
  20. Japanese writing looks so cool (normal font: Verdana or Arial)!
  21. All my Japanese vocabulary is from anime.
  22. What’s a fansub?
  23. I don’t know what this “doujinshi” is (never heard of it).
  24. I love doujin bands (has heard of “doujinshi” and “doujin” but claims to know what the meaing is).

Each question you answer “yes” is worth one (1) point. The more where you get more points is the category you fall into. Please note that this isn’t entirely accurate, since I don’t know everything (or a lot) about being a wap. Further, this doesn’t cover everything.

Which to use for an array? The answer is: foreach. Not only would you be able to get the keys and values, but it’s faster. If you don’t believe, try this (please excuse the extravagant amount of text):

<?php

/*
Tested, one at a time.
*/

function loadTime() {
$time = microtime();
$time = explode(" ", $time);
$time = $time[1] + $time[0];
return "<br /><br />Processing time: ".(microtime() - $time1)." seconds.<br /><br />";
}

//3266 bytes, not including the line breaks.
$string = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus nibh lectus, faucibus in, vehicula quis, gravida sed, risus. Fusce et neque venenatis felis faucibus placerat. Donec tincidunt, nisl rhoncus consequat tincidunt, nisi neque pharetra elit, et posuere sem nisi at magna. Nulla facilisi. Integer pretium elementum velit. Ut lectus mauris, lobortis vitae, blandit in, interdum pretium, tortor. Donec augue mauris, mollis hendrerit, laoreet sit amet, condimentum in, nulla. Suspendisse facilisis pharetra urna. Maecenas quis diam. Sed facilisis accumsan sapien. Ut feugiat metus et quam. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Integer egestas tortor ut sem. Sed venenatis pede ac orci sagittis vehicula. Suspendisse sed arcu eget magna dignissim adipiscing. Maecenas dapibus, augue id vehicula fringilla, nulla pede condimentum risus, sit amet blandit lectus felis nec lorem. Quisque mi urna, cursus at, ultricies sed, adipiscing a, libero.\n\nDuis magna ipsum, placerat eget, aliquam eu, condimentum et, felis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec nisi. Vivamus ac odio at nunc elementum lobortis. Aliquam erat volutpat. Nunc pellentesque adipiscing metus. Pellentesque nec tellus sit amet ligula gravida fringilla. Nunc consequat eleifend purus. Pellentesque nec neque. Ut vestibulum dui eget tellus. In laoreet hendrerit mauris.\n\nQuisque condimentum, quam sit amet vehicula cursus, nulla pede lobortis sem, nec luctus felis justo nec orci. Phasellus diam est, adipiscing a, ornare vitae, mollis in, nisl. Fusce purus quam, tincidunt ac, tristique feugiat, dapibus in, tortor. Duis ultrices. Pellentesque sed sapien non metus egestas porttitor. Ut nec metus. Aenean rutrum. Maecenas nec est. Cras sed enim. In sed leo at ligula vehicula interdum. Fusce iaculis dui quis nulla. Sed aliquam erat. Nullam in neque sollicitudin libero dictum porta. Ut tempor risus sed nunc.\n\nNam sit amet tellus. Donec semper, turpis in luctus aliquam, pede nulla vulputate diam, vitae eleifend turpis lectus vitae quam. Vivamus pellentesque. Morbi malesuada purus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nunc tincidunt nulla at sapien. Aenean non dui ac lectus rutrum pulvinar. Nam pulvinar quam vitae massa. Donec laoreet. Nunc eleifend ligula in metus. Etiam tincidunt. Morbi posuere enim et ipsum. Nulla nisi. Aliquam vel tortor. Donec pulvinar eros id nisl. Pellentesque in tellus. Sed orci lacus, tincidunt at, consectetuer ac, rhoncus eget, mi.\n\nInteger semper malesuada sem. Fusce in enim. Pellentesque varius semper libero. Suspendisse eu augue placerat arcu tincidunt pellentesque. Morbi tristique velit eget elit. Praesent fringilla viverra nunc. Duis accumsan nibh vitae nisi. Donec cursus vehicula dui. Vivamus massa est, malesuada ac, porttitor a, ultrices eget, mi. Integer gravida aliquet lectus. Phasellus laoreet luctus leo. Duis eget pede. Quisque ligula massa, dictum id, laoreet sit amet, ornare vel, mauris. Morbi sapien. Donec placerat malesuada quam. Curabitur iaculis. Etiam pellentesque arcu feugiat tellus. Praesent pulvinar euismod ligula. Cras ante sem, blandit dictum, eleifend ut, venenatis non, metus. ";
$explosion = explode(" ", $string);

print loadTime();
foreach($explosion as $k => $v)
{
print $k.":".$v."<br />";
}

print loadTime();
for($i = 0, $cnt = count($explosion); $i < $cnt; $i++)
{
print $explosion[$i]."<br />";
}

print loadTime();

?>

Results:

Processing time: 0.997527 seconds. (explode)
Processing time: 0.003688 seconds. (foreach)
Processing time: 0.004356 seconds. (for)

Using PHP5. Might depend on your server and PHP version.

Sakura Matou is probably my favorite girls of all the ones that I know. She’s on par with Yuki Nagato-chan.

Download-able version.

The import command in Python is one of my favorites (not joking). import allows the programmer to link (load) files and inherit all of the contents of that file (you can use whatever is in that file in another file). Here is the basic syntax:

import [module]

[module] is also called a file, but they’re referred to as modules. I’ll explain modules a little later. A little note: Python will execute whatever is in the file if it can. Meaning, you cannot store a file in a variable this way. It’d be like storing a file in a variable by using #include (C++) or require (PHP). Also, it must be a Python file (.py) and you do not include the extension (why is also explained). Finally, import loads the modules that the current file is in; for example, if you import a module and the file is the directory C:\Testing\Build, then Python will load (and execute) C:\Testing\Build\[module_name].

Ok, so say you don’t want to load the entire file. What is there to do? You can load a class from the file, like so:

from [module] import [class]

This means, from the module that is [module] only take the class that is [class]. Meaning, if you do this,

from foo import bar

Python will load bar from foo and only bar from foo. It won’t load anything else. You can use multiple classes as well,

from foo import bar, stool

Python will load only bar and stool from the module that is foo. Likewise, you can load multiple modules as well,

import foo, settings

However, you cannot do this,

from foo, settings import bar, UI

This will generate a syntax error, the most common error. Now, onto modules. A module is anything with Python code in it – that includes folders. Python supports folders acting as modules. How is this done? Like this,

import [folder_name]

The only difference is that there needs to be a __init__.py file in [folder_name]. Otherwise, Python will think the module doesn’t exist. Why would you want to do this? Mainly for organization. You can do this,

import [folder_name].[module]

Python will load [module] that’s in [folder_name]. Meaning, you can do this,

import source.settings

and Python will load the file source/settings.py. As long as there’s a source/__init__.py file, it’ll work. In fact, you can even do this,

from source import settings

and it’ll work. You cannot do this:

import source/settings

You’ll get a syntax error. You especially should not do this:

import source\settings

That’s just plain stupid and one of the worst syntax errors one can make.

I am not sure what the correct name is for this feature, but it does make function calling more convenient. Take this for an example:

<?php

function hold_the_line($soldier='Major Rawne',
$regiment_leader='Colonel-Commissar Gaunt',
$planet='Tanith') {
	print "Soldier: ".$soldier;
	print "Regiment Leader: ".$regiment_leader;
	print " from ".$planet;
}

hold_the_line($planet='Vervunhive');

?>

This is what I am talking about. PHP will completely ignore, deliberately or other, the $planet, thus outputting,

Soldier: Vervunhive, Regiment Leader: Colonel-Commissar Gaunt from Tanith

This makes default arguments all the more difficult. If you do this in Python,

def hold_the_line(soldier='Major Rawne',
regiment_leader='Colonel-Commissar Gaunt',
planet='Tanith'):
	print "Soldier: " + soldier
	print "Regiment Leader: " + regiment_leader
	print " from " + planet

hold_the_line(planet='Vervunhive')

you would get this,

Soldier: Major Rawne
Regiment Leader: Colonel-Commissar Gaunt
 from Vervunhive

Cool, eh? PHP needs this. Not sure if it’ll appear in PHP6.

Right, so one of my non-Japanese friends at school got a hold of the 5th edition of the Warhammer 40,000 rulebook – not only that, but it’s also one of the 4000 Limited Edition rule books. “OMG!!!!!!” is something along the lines of what I would type if I were 10 years old. I didn’t get a long chance to flip through it, but I did see another section of the current timeline added to the current: the Age of Ending. Apparently, the Emperor is losing the battle against Chaos and unfortunately dying. Perhaps when the Holy Emperor is in a near-death situation, the Illuminati will reveal itself to the Imperium? Perhaps there will be a Fall of Man, an event much worse (I hope not) than the Fall of the Eldar? Another Chaos God… there is enough Chaos filth already. Another possibility: by the death of the Emperor, humanity will finally develop an immunity to Chaos and its so-called power and filth.

If the Emperor does die, humanity fighting itself will be expected. The Adeptus Ministorum will be in ruins, no doubt. The Adeptus Mechanicus will follow its own agenda… chances are, they’ll see Tzeentch (more likely the Prince of a Thousand Faces) as their Machine God, while the rest go for the Void Dragon of the C’tan (From the book Grey Knights by Ben Counter, the Prince of a Thousand Faces is pure knowledge. He was also given a body by Tzeentch).

Another possibility, and I must say that it’s the worst, is that every single Chaos legions attacks Cadia. That will also be bad.