Officer in Civvies

The life of a soldier at a civilian university.

Archive for the ‘The Web’ Category

Back from Alberta

Posted by officerincivvies on June 29, 2009

So, I am back from racing in Alberta, I will tell about that, with pictures and results later. Now that I am back I am back to school work, and now I get to write a 10-12 page paper on Anti-State Terrorism and the Jihadist Movement in the United States. On top of that I need to start my CMPT-383 assignment and finish off my CMPT-475 assignment.

Once again I changed my mind on the topic of my classes for the fall. Now my five choices are: CMPT 470 (Web-based Systems), 456 (Web Search + Information Retrieval) and 412 (Computational Vision). CRIM 357 (Forensic Anatomy) and 315 (Restorative Justice). I opted to drop HSCI-120 (Intro to Human Sexuality) but I plan to sit in on lectures. CRIM-416 (Death Scene Investigations) does not seem to be offered anymore and CRIM 451 (Advanced Techniques in Forensics) is at the same time as CMPT 412. CRIM 315 is distance ed and seems pretty easy, just write one paper and do a journal and I decided to take another CMPT 4xx class to finish off the number of CMPT 4xx classes I need and that Brian Funt who is teach CMPT 412, his reviews make him seem not too bad.

I am also looking at getting hosting, I know most of you have hosting (I am just using a free wordpress host) but I woud like to get my own. Who would you recommend (besides Dreamhost) if you have hosting?

But now I am back to homework.

Posted in School, The Web | 5 Comments »

How to Mod Rewrite

Posted by officerincivvies on December 21, 2008

This tutorial of mod rewriting assumes you have some knowledge of programming and web developing.

One thing I have noticed while working with PHP is that often you will get really ugly urls that look like: www.example.com/test.php?var=foo&cat=1&prod=24afa.

These sure look disgusting. What is worse is that google will not look at your page because they are dynamically generated. So GG Google indexing your website. However, there is a way to deal with this. It is quite simple. It is called mod rewriting. I know this works with Apache but I am not sure about IIS. I don’t use it, never will so I am not going to bother with it at this second.

What mod rewriting will do is take that same URL and allow you to rewrite it to look like www.example.com/test/foo/1/24afa/.

WordPress uses it all the time. To do this you only need to edit or create an .htaccess file with two lines of code.

They are:

RewriteEngine On # Turn on the rewriting engine
RewriteRule ^test/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/?$ test.php?cat=$1&prod=$2 [NC,L] # testing out

The first line just tells the server to turn on the mod rewriting. The second line is our meat of our code. The second line, in this example allows you to turn: test.php?cat=something&prod=somethingelse into test/something/somethingelse. It should be obvious that you must make a rewrite rule for each URL that you wish to edit.

The rewrite rule line is made up of four parts and they are as follows: RewriteRule, new address, old address and exception rules.

The RewriteRule is always the same and it never gets changed otherwise the server wont know what to do.

The new address is what you want your URL to look like. You must use regular expressions to allow different types of variable input and you can have as many variables in the URL. In our example the new URL will look like: test/var1/var2/. We can see we have two variables in the URL and with the REGEX rules I have specified you can have only letters and numbers in the variables. A cheat sheet for REGEX can be found here. All new URLs must be defined between a ^ and a $.

Now we need to map this new URL to the file. We do that by specifying the file. In our example we have said the old URL was: test.php?cat=$1&prod=$2. This means the new URL will be mapped to the file test.php with the variables var1 and var2 being passed by HTTP GET to the specified variables in our rewrite rule (cat and prod).

The final part we need are the flags. Currently we have defined: [NC, L]. The NC means the matching should be case insensitive. The L defines that once it has matched a file we do not need to continue checking every line in the file, which can speed up load time of the web file. A whole list of mod rewrite flags can be found here. All flags have to be between the square braces and separated by a comma.

That is it, that is all that is needed to rewrite your URLs on your website. You should be able to do it.

Two last tips before you go off and try this. Make sure you don’t already have a .htaccess file as you do not want to lose whatever is in this file. If you already have this file, just append to the end of it the rewrite rules. Secondly, if you get a 404 error with your new URL, you may have entered non-valid characters into the variables of the URL.

I hope this has helped.

Posted in The Web | Leave a Comment »

Snow ((Hey Oh))

Posted by officerincivvies on December 21, 2008

Well… it is another snow day… this time it sucks because I can’t go to my grandparents house. Right now I am stuck in my townhouse being bored. Sure there are some things I could do like work on my website project, work on the rowing website, update the CRIM website, clean the house, read, write a letter for the peak etc.

This is what it feels like in Vancouver right now.

I was driving down hasting’s street this morning at 4 am to deep cover and the entire way was covered in snow. I am so glad that I had snow tires because there were so many cars that were stuck and not able to make it.

Instead I decided to finally install stumbleupon. The only reason I did not want to before was because I do not like toolbars on my web browser. They really annoy me, and they take up screen real estate.

I managed to find this really cool link, it reminds me of STOMP.

Posted in The Web | Leave a Comment »

A Day of Something and Nothing

Posted by officerincivvies on December 11, 2008

Well… even though school is pretty much done now, I just sit home and do nothing but I managed to get a bunch done today.

This morning I got my first grade, for CMPT-310, nothing I was too proud of but I was expecting it. The only reason I did so shitty was because of SFU’s scheduling of exams. I solely blame them.

Then I managed to get mod_rewriting for Apache working on my project website. All in all it was not hard, nor did it take me a lot of time to do. I will write about how to do that later. Basically it allows me to have UR-Ales of websites to be www.mysite.com/thread/202/1/ instead of www.mysite.com/thread.php?id=202&p=1. Makes it easier for google to index that, and it just generally looks nicer.

Then I woke up at 9:30 am, something I never do. Jesse phoned me and it woke me up, so I just got up. I also did some other firsts, such as making a full bacon, eggs, hash browns and toast breakfast. Something I have never had time to make in rez. I also watched some morning cartoons, Arthur specifically, reminds me of my childhood as it was the same episodes from ten years ago.

After lunch I played some Knights of the Old Republic 2. I started playing that game again since I find it fun. This time I am trying to be evil and I must say, I honestly have a hard time playing a bad character.

I headed across campus and picked up my distance education material for my two DE courses, Biological Explanations of Crime and Intro to Religious Studies. Both courses seem to be ridiculously easy. I have to do an interview with a religious leader in the community and I have to do a research paper on any topic I choose relating to religion.

For the interview I am going to try and contact someone at the church of Scientology. Jesse seems to be really excited about it and wants to help video tape it / record it. If the Scientologists won’t let me then I will end up probably asking some boring mainstream religion. As for the research paper, I have no clue.

I also picked up most of my textbooks. I like new textbooks. Most of them this semester are art courses and they don’t seem to be as boring. I had to order one book, my CRIM 356 book, off of amazon.ca because it is only recommended and the bookstore wont stock it.

Cory also seemed to have found half of the wireshark answers so I am going to type up those and we should be done the project soon and I will just run across campus and pass it in, hopefully I will also pass the class.

I also ran into this news piece about some Ontarian man who built a female android. The first thing I thought about was, “he probably has sex with it” and he openly admits to having built it with breasts/nipples/vagina and with sensors in those areas. It will talk dirty to you if you talk dirty to it and it has a huge dirty vocabulary. Reminds me of that thirty year old virgin who has to build an android to get laid. Although he wont admit this; he also claims he built it as a women instead of a man because a male android was too threatening.

… Soon these androids will be harvesting us for electricity while allowing us to believe we live in some alternate reality. I bet Vaughan and Mori think this is such a cool thing, and that Hadley thinks it is bad for our privacy and the overconfidence and arrogance of the programmer will lead to our demise.

Posted in News, School, The Web | Leave a Comment »

Unusual Deaths

Posted by officerincivvies on December 8, 2008

I came across this list of unusual deaths, from Cory, the other night. It was pretty hilarious/interesting in the way some people died.

Such as Mr. Hands who got f*cked to death by a horse, the girl who had her insides sucked out by a pool filter, a monkey who pushed a man off a balcony, a submarine that went from 9 to 1 atm in less than a second and then the strange events that happened in the Dyatlov Pass incident.

Posted in The Web | Leave a Comment »

Turing Would be Turning in his Grave

Posted by officerincivvies on December 7, 2008

Wow… impressive… http://www.getacoder.com/projects/bug_finder_92913.html

I am pretty sure it is a joke, but someone posting as AlanT is asking for programmers on those rent a coder style websites to solve the Halting Problem which Turing proved impossible.

I wonder if someone has tried to bid on the project?

Posted in The Web | 3 Comments »

How to Write Forums in PHP

Posted by officerincivvies on November 15, 2008

Having worked with PHP for over 6 years I have done many things with PHP. One of the biggest things that I have made a number of times are forums. Sure I could use PHPBB or Phorum or anything that is already made. Instead I tend to make my own which are a lot more lightweight, have the features I want and be able to customize it much easier.

I have made a number of forums. The first ones I made would have been back in 2004. Being new to PHP I didn’t know much. My biggest problem was to distinguish a normal post from a reply. To deal with this I just created two tables. One was called forum_thread_start and the other being forum_thread_replies.

Of course working with this was not the most easiest because I had to deal with two different tables and I didn’t know the best way to handle it. So on the first thread page I would first call the thread_start post and then nine replies. This required to MySQL queries and having to align to loops. After the first page I would just select the replies.

This also lead to more problems, or more so, lack of knowledge on my part. To update the number of replies in a thread I would increase a counter in thread_start_post every time a reply was made instead of using the COUNT(*) function of MySQL.

The next time I made forums, maybe in 2005 or 2006, I had much more elegant solution. Instead of two tables, I just had one, forum_threads. To distinguish the difference between the first post and other posts I used a column that was a simple binary switch to tell the difference. This was a lot more elegant but still not the greatest idea, and for some reason I still had that damn replies column.

Recently I started on a new set of forums, so far I am really happy with these. I have one table called forums_posts. In it there is only a handful of columns: id, fid, tid, message, title, poster, dateline, locked, deleted and important. As you see I also got rid of the replies post. On the forums page, to select all of the thread starters I just go like so:

SELECT * FROM forums_posts WHERE fid='$fid' AND deleted = '0' GROUP BY tid ORDER BY important DESC, MAX(dateline)

And so far it is working. I just finished off the forums and they are really great. At this moment I am not going to link to them as they are part of a project I am working on that I will not release till it is not. So if you want to see them you just have to wait.

Posted in The Web | 2 Comments »

How to PHP on your SFU Webspace

Posted by officerincivvies on November 10, 2008

So I spent the last few weeks trying to get PHP to work on my SFU webspace. It should have been as simple as uploading a .php file and then executing it. Think again.

First of all you need to create a folder in your pub_html directory called “cgi-bin”. Now in here you have to put in all of your PHP files. Obviously the extension has to be .php.

Your php file, the first line most contain the following line of code:#!/usr/local/bin/php. Once uploaded you must chmod the file to 700 or set the owner to Read-Write-Execute and nothing to anyone else.

Now you can’t just go to your webspace like normal. Instead of http://wwww.sfu.ca/~unixid you have to go to http://cgi.sfu.ca/~unixid otherwise don’t even think about trying to load that script without a 500 error.

If you still cannot get your PHP file to run then you either have a problem with your code or you need to contact ACS @ help@sfu.ca.

Posted in School, The Web | Leave a Comment »

Mad World

Posted by officerincivvies on June 23, 2008

I know this has been out for a month now, but since Maddox only writes a new post once every four months, it takes me a while to notice.

Posted in The Web | Leave a Comment »

“First Post” and Facebook

Posted by officerincivvies on April 4, 2008

In the words of Dean Hum, “FIRST!”.

Anyways, this is my obvious first post on this blog, I do not know yet if I am just playing with WordPress or if I am actually going to blog.

The other day I decided to disable my Facebook account for a numerous amount of reasons, the biggest being that there is nothing that it gives me. I joined back in September of ‘06 to see what it was like, this was long before everyone who had access to the internet could join. Since then it has gone downhill specifically with the addition of applications. What amazes me is how offended people can get by what happens on that site. I know lots of people who take it is as something really offensive if you remove them as a friend, or others who get furious if you add others as friends. It is ridiculous. It has been Five days or so since I removed it and so far the only effects I have found from disabling my account is that I no longer receive a plethora of emails from the site telling me some person has sent me an invitation to some account.

That’s just my view on the Facebook, so now I have to go finish/start my 300 assignment, start studying for finals and get ready for California and who knows how long till BOTC since the military won’t know tell the Friday before.

Posted in The Web | Leave a Comment »