Jun 12

Site Updates

Oh goody goody, I’ve updated the website! What changes do we have in store right now?

Well, we are now using NBBC to do parsing of BB code and related stuff. This means that the style of the website has changed slightly, but I find that’s acceptable.

I came across NBBC the other week when I was looking for a BBCode parser. I realized that it was rather dumb of me to write my own parser. While it would be cool, it would take a long time and potentially wouldn’t work so well. So, we took something that was already made and then slammed it into the website. So far, so good though. 🙂

May 20

Comments

Holy moley, that’s a lot of comments!

Unfortunately, they’re all spam. On the bright side, adding comments apparently works!

To prove it to you:

mysql> DELETE FROM comments;
Query OK, 311 rows affected (0.12 sec)

Yeah… we’ll be integrating a CAPTCHA system soon, possibly tomorrow.

On the bright side, this website is actually being utilized! Of course, perhaps that’s not such a great thing… Ah well, what are you going to do?

Apr 05

How to: Survive on $20 a week

Okay, so I haven’t updated this in a while. I’ve also been quite bad about not going over my $20 limit. But for all of you out there who care(about three people I believe), I will post a detailed expense report at some point in the future. Today, I will talk about the basic ideas about how you can survive on $20 a week.

First off, I think in terms of one week at a time. Since I am the only person who eats what I buy, it’s very easy to buy a lot of food to feed myself for a week. For example, one week I got a pound of ground beef, sour cream, cheese, shredded lettuce and taco shells to have a taco-themed week. Those supplies lasted the entire week for me, so that way I didn’t have to go out and buy anything new.

Second, grain products. Now, a co-worker of mine has some research that says that wheat is not particularly good for you – he only eats fruits, vegetables, and meat from cows not treated with some chemical that I don’t know the name of. I can’t vouch for any of this because I haven’t read the research, but unfortunately a diet like this is going to be rather expensive. Grain products are much cheaper, and that is how you can keep costs down. I keep a supply of spaghetti and macaroni and cheese handy. I buy a 12-pack of macaroni and cheese so that I will have enough to keep me for a while. Each box of spaghetti has probably about five meals for me, and at $0.79 a box it’s insanely cheep.

Third, buy in bulk when possible. A 12-pack of macaroni and cheese will last you a significant time if you don’t eat much. I don’t buy many perishable items in bulk, because I would never eat them before they went bad. However, I do buy frozen items in bulk, because they will of course keep a long time.

Fourth, buy canned fruits and vegetables. Again, it’s more expensive to get fresh, but I don’t mind the canned fruits. Personally, I can’t stand canned vegetables(I get frozen ones), but canned pears and pineapples are very cheep.

Fifth, DON’T BUY LUNCH! Bring your own. I like to bring a peanut butter sandwich, a small pack of fruit(individual serving size, I have not been able to find a good container that does not leak. It’s more expensive than buying in a tin can, but it doesn’t leak), and some animal crackers. Total cost of this lunch: probably about $2.00. Total cost of a cheap lunch: $5.00. Total cost of a lunch that you would probably get: $8.00. Let’s do the math here:

$2.00 x 5 days a week = $10
$5.00 x 5 days a week = $25
$8.00 x 5 days a week = $40

Yes, it really is that cheap to bring your lunch. It saves a lot of money.

Mar 06

How to: Survive on $20 a week

Today marks the start of a new series on here, how to survive on $20 a week for food. In this, I am going to attempt to survive solely on $20 a week for food. A few things before we get started though:
[list]
[*]I may go over the spending limit some weeks – this is because I, like everybody else, can be lazy and sometimes you just have to go out because of time or whatever. So, this is more of a general guide – I will try to not go out to eat whenever possible.
[*]Each week, I get $20 more to spend on food. Unused balance from the previous weeks roll over.
[*]The first week, I get $40.
[*]This $20 is solely for food – not for other supplies like soap, rent, etc.
[/list]

Anyway, on to the food!

I went to the store earlier today, and got the following items:
[table]
[tr][th]Item[/th][th]Price[/th][/tr]
[tr][td]Bread(small loaf)[/td][td]$0.59[/td][/tr]
[tr][td]Cheddar cheese(16 oz)[/td][td]$3.99[/td][/tr]
[tr][td]Mozzarella cheese(16 oz)[/td][td]$3.99[/td][/tr]
[tr][td]Butter[/td][td]$2.49[/td][/tr]
[tr][td]Milk(1 gal)[/td][td]$1.89[/td][/tr]
[tr][td]Peas(40 oz, frozen)[/td][td]$2.29[/td][/tr]
[tr][td]Instant mashed potatoes(13.75 oz)[/td][td]$1.69[/td][/tr]
[tr][td]Cheddar cheese(16 oz)[/td][td]$3.99[/td][/tr]
[tr][td]Chicken nuggets(26.5 oz, frozen)[/td][td]$3.99[/td][/tr]
[tr][td]Pears(in individual bowls, 16 total)[/td][td]$6.00[/td][/tr]
[tr][td]Peanut butter[/td][td]$1.29[/td][/tr]
[tr][td]Apple Juice(64 oz), 2[/td][td]$3.98[/td][/tr]
[tr][td]Grapes[/td][td]$2.77[/td][/tr]
[tr][td]Animal Crackers(3lb)[/td][td]$4.69[/td][/tr]
[tr][td]Pizza dough[/td][td]$2.29[/td][/tr]
[tr][td]<b>Total:</b>[/td][td]$41.94[/td][/tr]
[/table]

Alright, so I went a little over. The good news though is that some of these are one-off purchases that won’t have to be made for a while. For example, the mashed potatoes I expect to last 4-5 months, which given that I’m only back at school for 3 could prove to be somewhat problematic. As well, the pear bowls that I got should last for about three weeks, as should the peas. The grapes I got because I felt like having some grapes. The cheese is for the pizza dough, I am going to make some tonight. I won’t be using up all of the cheese, but I plan to make tacos next week so I can use the cheese for that.

That’s a start. I’ll post more once I eat some more, and we’ll see where we are at!

Jan 29

SHEER BRILLIANCE

So I just watched The Incredibles because, you know, it’s a Pixar movie. And anything that Pixar makes is awesome. I mean, Pixar could make anything great. But anyways, one of the special features is about a deleted scene. What they were originally going to have was a pilot who flew the plane to the island, instead of Mrs. Incredible. The scene was basically the pilot flying, and then being shot down while the Incredibles escaped, and Dash asks “What about the pilot?”

Now, what would be totally awesome, was if this was a cameo for H. M. Murdock.

Yes. Murdock from The A-Team.

The rest of the movie could stay exactly the same, there’d be no need to change it. But at the end, there’d be a brief scene with all of the A-Team around Murdock in a hospital bed. And then Murdock asks: “So what’s the plan, Hannibal?”

Or something like that.

Jan 15

D-Bus tutorial finished

D-Bus tutorial finished. It should cover all major aspects of D-Bus, using both method calls and signals. I’ve tried to make it as clear as possible, but I’m afraid that it may not be quite clear. Hopefully it will be useful to people.

On a related note, this has caused me to greatly increase the features available on the website. BBCode now works(only for pages at the moment though). I do however need to make it more robust. At the moment it’s highly likely to break if bad input is introduced. In order to make something that looks good, I’m going to have to write some sort of tokenizer it seems. That way I can replace only certain instances. i.e. I want to make it so that each paragraph is enclosed by a <p> tag, but I don’t want that tag inside of code or quote blocks. Well, maybe inside of quote blocks, but definitely not code blocks. It makes it look weird.

Jan 13

D-Bus tutorial

So at work, we use D-Bus to allow our programs to talk to each other. However, when first learning how to use D-Bus, all of the information that we were able to find on the internet was either laughably out of date or otherwise useless. So I’ve taken it upon myself to create a good tutorial that shows you exactly how to use the D-Bus. Hopefully, you can find it helpful.

Note that it’s not done quite yet. I’m going to add more information on signals, plus sample code once I’m done. I should have time to finish it this weekend.

On a related note, the tutorial is the first page that uses my new page-generator. It’s basically the same as a new post, but it’s more static to the extent that it will stay on the left hand side under ‘navigate’. With this in place, we are coming up on a fully-featured CMS system. Of course, this is nowhere near ready to release, but the basic framework is mostly in place at this point.

Jan 11

RM5248: Now with comments(really!)

So I’ve finished up the comments feature of the website, and it appears to be working properly. Currently, I have it set to allow guests to comment as well. It seems to be rather good.

On a related note, viewing a post is now in its own separate page, as opposed to a parameter to index.php. I think that it looks a lot better that way.

More features to come soon.

Oh, I almost forgot: This website should be fully XHTML compliant; I have not checked the new pages, but up until this point the entire site is good. Standards checks are a good thing.

Jan 08

Adventures in PIC programming

Recently, I got a PICKit2 programmer from Microchip, for a project. I haven’t started, I’ve just been learning my way around the chip, using the included lessons. They’re somwhat lacking though, so from time to time I’ll post some (possibly useful) information on here.

Just so we’re on the same page, I’m using the second type of PICKit2 that Microchip sells, the DV164120.

Now, on to the possibly useful part. The first lesson is to turn on a single light, and the 4th lesson is to make those lights rotate around and chase each other. It took me a while to figure out exactly what was going on, so let’s go dive into lesson 1.

Start:
bsf STATUS,RP0 ; select Register Page 1
bcf TRISC,0 ; make IO Pin C0 an output

bcf STATUS,RP0 ; back to Register Page 0
bsf PORTC,0 ; turn on LED C0 (DS1)

goto $ ; wait here
end

This is relatively simple, so let’s try and set two LEDs on at a time. First, let’s make all of PORTC to be output. That code is given in Lesson 3. Plus, let’s set the second bit on PORTC to set the second light on.

Start:
bsf STATUS,RP0 ; select Register Page 1
clrf TRISC ;from lesson 3, set all of TRISC to output

bcf STATUS,RP0 ; back to Register Page 0
bsf PORTC,0 ; turn on LED C0 (DS1)
bsf PORTC,1

goto $ ; wait here
end

However, this doesn’t work! You’ll notice that only LED C1 turns on. Huh. That’s interesting, because we definitely set two bits, bits 0 and 1 to turn on DS1 and DS0.

Well, so what would happen if we were to, say give the bsf command a hex value that had both bits 0 and 1 set, like 0x03? Well, as it turns out, that will actually turn on DS4. What?!

The key here is that bsf is setting the [i]bit[/i] value. Basically, you give it a variable and you set the actual bit in that region. However, you can also load in a value to that region, which is what the rotate lesson does. Now, let’s look at the datasheet for the PIC, and look at the PORTC:

Notice how this is only 7 bits. These bits control which outputs are on at a time. We’re only concerned with the first 4 bits, because we only have 4 lights plugged into the PIC. Now let’s look at the relevant code for the rotate that sets what light to put on:

 bcf STATUS,C ; ensure the carry bit is clear
rrf Display,f
btfsc STATUS,C ; Did the bit rotate into the carry?
bsf Display,3 ; yes, put it into bit 3.

Basically, what this does is it clears the carry bit, which is in the STATUS register. Now, we rotate the Display variable to the right, after moving it into f. Let’s step through this from the starting point, where Display has the value of 0x8(note that the Microchip code has this as 0x08, however only one byte is relevant and needed, since PORTC is only 8 bits(1 byte) wide). The next part shows only the last 4 bits of the byte, as those are the only relevant bits for this example.

1000 ;display at beginning
0100 ;rotate display to right, in C this would be Display &gt;&gt; 1
;is there anything in the carry bit? no, don't put anything in bit 3
0100 ;display next loop
0010 ;display after rotate
;is there anything in the carry bit? no, don't put anything in bit 3
0010 ;display next loop
0001 ;display after rotate
;is there anything in the carry bit? no, don't put anything in bit 3
0001 ;display next loop
0000 ;display after rotate
;is there anything in the carry bit? yes, set bit 3
1000 ;display at end. repeat

Now back to our original question, which was how to set multiple lights to be on? Well, we need to do basically the same thing that we did for the rotate. We make a variable, and then we load the [i]variable[/i] with the hex value of what two lights we want on.

cblock 0x20
Display
endc

org 0
Start:
bsf STATUS,RP0 ; select Register Page 1
clrf TRISC ;set all IO pins C to output

bcf STATUS,RP0 ; back to Register Page 0
movlw 0xA ;1010 binary. Lights DS2 and DS4
movwf Display
movf Display,w
movwf PORTC
goto $ ; wait here
end

Simple once you understand it.

Jan 08

RM5248: Now with comments(almost)

I’m currently working on adding the ability to add comments to news posts. The framework is in-place, but I think that I need to re-work some of the website in order to make this more customizable. So, you can’t actually add any comments yet. I’m feeling rather lazy at the moment, and so I don’t feel like finishing it tonight.

So hopefully later this weekend. But because of what I want to do, it will take a little bit. Basically what I want to do is to make it possible to turn comments on and off, as well as have the ability to allow anonymous users to post comments. That’s something that I need to work on to allow maximum control over what is on the site, so that non-computer-savvy people can make a website for themselves and easily update it. This means that it would probably be a good idea to break out the viewing of individual posts into their own page, as right now that is all done thru index.php, and if I wanted to add more settings it would get very large and difficult to maintain. So, if I break it out into different pages I can make it cleaner.

I think that I am also going to look into re-working some of the SQL strings, making more use of PEAR to get values and insert values. Hopefully that will make it fully database-independent.