Pyune!

Home of the PIG

Coding conventions

Today at work:

s: zomg.
s: “Variable NOTDEFINEDVARIABLE is undefined.”
s: who coded this crap!?
c: LOLLLL
c: hahaha
c: that’s something you would see on digg

Lesson to be learned? If you expect a variable to be undefined, then error check it so that it isn’t undefined. When writing a program, never assume that you are the only person who will ever look at that code. So don’t write code that makes you look like an ID 10 T.

Chris

No comments

Happy New Year 2008!

New dreams, new goals, new hopes…and new equipment.

This is my first blog entry on the new server I just built that is hosting Pyune!.  A major upgrade from a Intel Pentium III 500MHz with 512MB of memory to a blazing AMD X2 4400+ 2.2GHz Dual Core system with 2 GB of dual channel DDR2 RAM.  Thank you for all the donations.

With the upgrade in hardware, I also updated all the software to the latest versions. It took me a while to get the php to operate correctly with IIS, which is why the blog has been MIA for the past 6 months. But finally it is working after many attempts.

I am happy to say that Pyune.com will be offically up and running by January 27th, in honor of Wolfgang Mozart’s birthday.

Happy new year everyone!

No comments

Hangovers: What is it and how to get rid of it faster

Prevention/Remedy rules:

1. Don’t ever drink. You’ll never get a hangover for the rest of your life.

2. Burnt toast. The activated carbon acts like a filter, attracting the congeners.

3. Fried/Fatty Foods. Eat this before drinking. This will stick to the stomach wall longer, slowing down the absorption of alcohol into the bloodstream.

4. Eggs. Eat the day after. Not only provides energy, but also contains large amounts of cysteine, which helps break down acetaldehyde.

5. Bananas. Eat the day after. Replenishes the body with electrolytes and potassium.

6. Water. While drinking, drink at least a cup of water per alcoholic drink. This dilutes and slows down the affects of alcohol, giving your body more time to break up the toxins.
The day after, drink lots of water to replenish what was lost. Adding salt and sugar to the water also helps. Caffeine-free, non-carbonated sports drink achieves the same effects.

7. Fruit Juice. Fruit sugar re-energizes the body. It also replenishes the body’s vitamins lost from alcohol.

8. Time. The complete cure for hangovers. Let the body clean the toxins up.

OVERVIEW

Before drinking:

  • Eat a full meal: your diet should include fatty foods and carbohydrates.
  • Drink at least a glass of water.
  • Take multivitamins. Prepare your body for the good stuff.

While drinking:

  • Drink in moderation.
  • Drink at least a glass of water after every alcoholic beverage.
  • Watch your drink choice:
    • Beer: Though it has lowest alcoholic content (usually 3-6%), it is carbonated, which speeds up the absorption of alcohol and toxins.
    • Wine: Higher alcoholic content than beer (usually 7-15%), but is not carbonated. White wine is better than red because it has less congeners. In general, the cheaper the wine, the higher the congener content and the worse the hangover.
    • Liquor: This has the highest alcoholic percentage (25-75%). Clear liquor (vodka, rum, gin) are better than dark burbon, whiskey, tequila because they have less congener. In general, cheaper liquor will result in a worse hangover than more expensive liquor.

After drinking:

  • Right before bed, drink a glass of water. This will reduce the effects of hangovers.
  • After you wake up, drink more water.
  • Eat breakfast to replenish the energy lost during last night’s extravaganza.
  • Take another multivitamin supplement.

Here is a list of drinks that help reduce the hangover effect: Mixers

By taking these steps carefully, you can have a regret-free night of fun and experiences. Always remember NEVER drink and drive.

Cheers!

How hangover work? Click on Read More…

Read more

1 comment

The largest rubber duckie I’ve ever seen

Honey, I blew up the rubber ducky!

This is just one of Florentijn Hofman’s many contemporary works of art. Locate on the Loire River in France, spectators gaze off into the waters as they are approached by a giant yellow Rubber Duck. The duck greets these friendly folks by slowly nodding its head. Best of all, the rubber duck is soft, friendly and suitable for all ages. Sign me up for the next bubble bath!

Rubber Duck at Bay

Bird on Duck

Title: Rubber duck
Year: 2007
Location: river the Loire, France
Dimensions: 26 x 20 x 32 meters
Materials: inflatable, rubber coated PVC, pontoon and generator
Assigned by: le Lieu Unique and the Biennial Estuaire
Florentijn Hofman’s Projects

No comments

How Gullible Are We?

A student at Eagle Rock Junior High won first prize at the Greater Idaho Falls Science Fair. He was attempting to show how conditioned we have become to alarmists practicing junk science and spreading fear of everything in our environment. In his project he urged people to sign a petition demanding strict control or total elimination of the chemical “dihydrogen monoxide.” And for plenty of good reasons, since:

1. it can cause excessive sweating and vomiting
2. it is a major component in acid rain
3. it can cause severe burns in its gaseous state
4. accidental inhalation can kill you
5. it contributes to erosion
6. it decreases effectiveness of automobile brakes
7. it has been found in tumors of terminal cancer patients

He asked 50 people if they supported a ban of the chemical.

* Forty-three (43) said yes,
* Six (6) were undecided,
* Only one (1) knew that the chemical was water.

The title of his prize winning project was, “How Gullible Are We?” He feels the conclusion is obvious.  I hope you didn’t fall for this either.

No comments

Baby Carrots are not babies at all

Have you ever bought a bag of “baby” carrots? Did you notice that they taste very unlikesterile, uniform and tasteless regular carrots? There’s a reason for that; there’s no such thing. They’re not underdeveloped carrots plucked from the ground while they still have that cute rounded uniform embryonic shape. (Thanks for pointing this out, Wise Bread blog.)

Baby carrots are actually regular carrots that aren’t aesthetically pleasing enough for North American supermarkets, cut into uniform size and shape.

It used to be that up to 70% of carrots were thrown out for not looking pretty. In 1986, a California farmer came up with the idea of making them “babies”.

Problem is, they’re more expensive than regular carrots. They also don’t taste as good. They’re made from a variety of carrot known as the Imperator, bred to grow faster and ripen quickly, and because of this, they only have 70% of the beta carotene of a normal carrot and a bland flavour. I’ll stick to regular carrots.

No comments

A guide to etiquette

Last weekend, my roommates and I went to the Clay Pit, a business casual-type restaurant with the most amazing Indian food. Those who know me realize that I have no etiquette whatsoever. The typical rules do not apply- I eat with my hands, leave soiled napkins on the table, and reach across the table to gain access to food.

Inappropriate etiquette is acceptable when you are with close friends and family, but what are the rules when you are with business associates or on a date?

Below is a list of etiquette “rules” that I was unfamilar with:

1) Americans eat continental style: fork is in the left hand and knife is in the right hand. If there are multiple forks and knives, start from the outside in. In England, fork is in the right hand and knife is in the left.

2) Always pass food around. Likewise, pour drinks for the other guests before pouring for yourself.

3) It is okay to put milk and sugar in your tea and coffee.

4) Napkins are never used to blow your nose in. Napkins should be placed in your lap.

5) Never ask for a box for your leftovers at a formal restaurant. It is considered appropriate to leave “leftovers”

6) When eating peas, they should be crushed with the prongs of your fork.

7) To eat pudding, one should break the dessert with a spoon.

Etiquette is important, but a real pain. Hand over the pizza!

-Steph C.

1 comment

Vodka: What else is it good for?

Here are some fun/useful facts that you can do with vodka:

1. To remove a bandage painlessly, saturate the bandage with vodka. The solvent dissolves the adhesive.

2. To clean the caulking around bathtubs and showers, fill a trigger-spray bottle with vodka, spray the caulking, let set 5 minutes and wash clean. The alcohol in the vodka kills mold and mildew.

3. To clean your eyeglasses, simply wipe the lenses with a soft, clean cloth dampened with vodka. The alcohol in the vodka cleans the glass and kills germs.

4. Prolong the life of razors by filling a cup with vodka and letting your safety razor blade soak in the alcohol after shaving. The vodka disinfects the blade and prevents rusting.

5. Spray vodka on vomit stains, scrub with a brush, then blot dry.

6. Using a cotton ball, apply vodka to your face as an astringent to cleanse the skin and tighten pores.

7. Add a splash of vodka to a 12-ounce bottle of shampoo. The alcohol cleanses the scalp, removes toxins from hair and stimulates the growth of healthy hair.

8. Fill a 16-ounce trigger-spray bottle and spray bees or wasps to kill them.

9. Pour 1/2 cup vodka and 1/2 cup water in a freezer bag and freeze for a slushy, reusable ice pack for aches, pain or black eyes…

10. Fill a clean, empty jar with freshly packed lavender flowers. Fill the jar with vodka, seal the lid tightly, and set it in the sun for 3 days. Strain liquid, then apply the tincture to aches and pains.

11. Make your own mouthwash by mixing 9 tablespoons powered cinnamon with 1 cup vodka. Seal in an airtight container for 2 weeks. Strain through a coffee filter. Mix with warm water and rinse your mouth. (DON’T SWALLOW!)

12. Using a cotton swab, apply vodka to a cold sore to help it dry out.

13. If blister opens, pour vodka over the raw skin as a local anestheic that also disinfects the exposed dermis.

14. To treat dandruff, mix 1 cup vodka with 2 teaspoons crushed rosemary. Let sit 2 days, strain through a coffee filter, massage into your scalp and dry.

15. To treat an earache, put a few drops of vodka in your ear. Let sit for a few minutes, then drain. Vodka will kill the bacteria causing pain in your ear.

16. To relieve a fever, use a washcloth to rub vodka on your chest and back as a liniment.

17. To cure foot odor, wash your feet with vodka.

18. Vodka will disinfect and alleviate a jellyfish sting.

19. Pour vodka over an area affected with poison ivy to remove the urushiol oil from your skin.

20. Swish a shot of vodka over an aching tooth. Allow your gums to absorb some of the alcohol to numb the pain.

21. If all else fails, just turn the bottle upside-down and drink it. Then nothing else will matter anyway!

Resource: http://cybour.50webs.com/Resources_Useful_Vodka_Tips.html

No comments

CSE 131A Compilers

Compiler: A program used to read in code (of another language), intepret what it all means, and run it. You think programming is hard, producing a compiler is even harder. But on March 12 2007 at 11:59 pm, my partner (Tim Mar) and I successfully completed writing a compiler in Java for Onyx, a subset language of XQuery (a database langauge). The output is xml, something similar to html. Ever wonder how Apple itunes stores the song data, which playlist it goes under, number of times you’ve played it, your rating? They store it in an xml file (C:\Documents and Settings\”YOURNANE”\My Documents\My Music\iTunes\iTunes Music Library.xml).

Want to learn how a compiler works? Here are the steps in which we designed our compiler:

1) Scan in the code using JFlex, a library used by java to read in words and separate it into what we call tokens by order of what kind of word it is: keyword, string, comment, symbol, variable name etc.
For instance:

let $chris := “human”
if( $chris = “human”) then “He is AWESOME!” else “Sigh”

Keywords are:

let, if, then, else

Symbols:

:=, =, (, )

…i think you understand the rest.

2) Parse, or syntax analysis, means the process of analyzing the sequence of tokens into some formal grammar. Basically, it determines the order of how to interpret the tokens read in by the lexer
(see part 1). Here is an visual example of the parsing process:

Parsing into a Tree

This is also the place that takes care of precedence. Multiply/divide comes before add and subtract and so on. We used a library called Java Cup in our parser design.

3) Lastly, but most importantly, is to interpret the tree created from the parser. This part is required the most amount of time to implement, because there are so many operations and keywords that we have to account for. So yes, we had to make sense of what “3+4″ meant and what the correct answer should be. Also, this language allowed for users to have their own functions along with overloading of other functions, so we had to created a function table that kept track of all functions including the builtin functions. If you’ve ever taken a programming class, you would understand the importance of variable scope. In other words, when a variable is declared, where can it be use and where is it not allowed to be used at all. So we also created a symbol table that took care of this delimma.
The output, or return value, is written in a xml file. For instance:

Input: 3+4
Output: <?xml version=”1.0″ encoding=”UTF-8″?>
<onyx-result>
<Result>7</Result>
</onyx-result>

4) We all know that no one can write code perfectly their first time without running into some syntactic or schematic errors. So it would be wise to output the line/col and error type if an error is ever encountered. Not only that, but if someone tries to add 3 + “some string” an error should also be thrown. Our compiler did not only the usual error reporting, but in case the user tries to call an overloaded function incorrectly with wrong parameter types, we also printed out all the possible matches that the user might have wanted to use. Nifty.

Well, there you have it. A very brief outline of how a compiler works and how it is created. It seems complex at first, considering our compiler consisted of 11,279 lines of code (including comments and spaces) distributed out over 89 files with over 120 hours of blood and sweat. But given about 3 months and lots of dedication, anyone can create their first compiler.

But before you set out on your down, keep these in mind:

  • Understand how the language you are trying to compile works
  • Find a friend who will stand by you and share the ambition as you do
  • Say bye to your other friends, for you won’t see them for a LONG LONG time.
  • Stay on task. Don’t lag behind like we did.
  • TEST TEST TEST!
  • Most importantly: NEVER GIVE UP!!

Good luck!

No comments

Blood Alcohol Content

I have a date with an awesome girl at Yamashiro, an expensive, fancy Japanese restaurant up in Hollywood Hills, and we’re both 21. Yes you know what that means.  A fancy date wouldn’t be complete without a glass of wine.

But the problem is, I am driving and I can’t drink that much. In fact, I shouldn’t even be drinking at all, otherwise I would be endangering both our lives and probably others. So what is the limit on my blood alcohol level before I get a DUI?  Well I did my research and apparently, by law, we can have a BAC of .08%. That’s about 2-3 glasses of wine depending on your weight. It’s scary when you think about it. So legally, I can have at least one glass of wine before I get arrested for DUI.

Here is a link that theoretically calculates your BAC:

http://www.ou.edu/oupd/bac.htm 

But regardless, you should not drink at all if you care about the lives and safety of yourself and others. I am positive the girl will not look down upon being the DD. If she does, well maybe you should consider finding a new one.

1 comment

Next Page »

Mexico