Jump to content


Check out our Community Blogs

marwex89

Member Since 19 Jul 2008
Offline Last Active Oct 06 2013 09:41 AM
-----

#542500 who thinks there should be more community projects?

Posted by marwex89 on 13 February 2010 - 08:37 AM

I think that you should stop dreaming with projects that you can't even understand. I have seen many "wanna be" posts like yours about large projects, in your case, an mmorpg. Do you have conscience of what is needed in order to build a game like that? And what you need in order to maintain it? Dreaming is good then we can build them. You're probably a kid that dreams with games at night... What you expect from here? you don't know nothing about C++ and programming at all and you're expecting that someone here is just going to build a very large and demanding application just to satisfy your desires? You don't even make sense, neither this post. Nobody is going to work for you, that's pretty obvious, and even a kid can see that...


That was a bit harsh, dude.
  • 1


#513688 Physical coordinate system

Posted by marwex89 on 07 October 2009 - 05:51 PM

The logical coordinate system is the coordinate system of your device context. You can define your own logical coord system using functions like SetViewportOrg(), SetWindowOrg(), SetMapMode() and what not.

The device coordinate system is the coordinate system used for your device. Your screen might for example have a coordinate system of 800x600 pixles (lol) or 1680x1050 pixles. This can also be changed (change screen resolution).

I guess this is what you mean by physical coordinate system. The real physical coordinate system is however the native resolution of your screen (or printer or whatever) and can not be changed.
  • 1


#506593 Rolling vs. Fixed Releases

Posted by marwex89 on 07 September 2009 - 09:19 AM

Yeah, but in the long run I guess it's good for Linux to have user-friendly distros as well as power distros. That means more people will use Linux, which again means that Linux gets more attractive. Which again means that more developers will put effort in making it even better.. etc. etc.
  • 1


#492328 LiveUSB - Take your system with you ANYWHERE!

Posted by marwex89 on 26 July 2009 - 01:14 PM

Your system on a USB Flash Drive -

TAKING IT WITH YOU ANYWHERE



I have recently tried out a technology that I have come to find really handy, the LiveUSB. For Linux users, the concept of LiveCDs should be familiar. The LiveCDs contain the whole operating system, allowing you to try it out without making any changes to your computer or existing setup whatsoever. One inserts the CD, tells the computer to boot from it, and boots from it, ending up in the OS on the CD. This is a very popular way to try out different Linux distros. Now, LiveUSBs are basically the same thing, on a USB flash drive. Your entire OS, including applications, documents and whatnot, on a flash drive. Handy. The advantage a LiveUSB has over a LiveCD is quite simple. You can't easily write to a LiveCD (and who carries CDs in their pockets?). Some operating systems allows you to store your settings, applications etc. on a hard drive, but if you insert the CD in a different computer: it is all gone. There are exceptions (OSs burning to CD-RWs), but they are rare. LiveCDs are great for trying out an OS, but if you actually want a "pocket-OS" to take with you, a LiveUSB is the way to go. So in this tutorial I will go through the steps to create such a USB drive.

If you didn't quite get the last paragraph, and/or want a bit more information about LiveUSBs before continuing, I can recommend the Wikipedia article on the subject: Live USB - Wikipedia - don't worry, it's short.


The ingredients

To make a bootable USB flash drive containing your OS, you need a few things:

* The most obvious one is perhaps a USB drive. The required size of this depends on the OS you plan on installing. A full Ubuntu install will take a lot more space than a tiny DSL install, for instance. If you have 4GB or more you should be fine in any case. And large USB drives are cheap, so just go for it. I used my 8GB SanDisk Cruzer Micro. This was originally a U3 drive. If you don't know what a U3 drive is, you could always look it up. Anyway, I uninstalled that so that I could use it for this instead. That U3 thing didn't really seem so cool to me anyway. One thing to remember is that a LiveUSB flash drive will usually wear out faster than a normal USB flash drive (unless the OS you install is running in RAM, more on this later). Yes, USB flash drives do wear out, as flash storage has a limited number of writes. Therefore, you might e.g. want to buy two drives, so that you can have a backup drive. This does not apply to USB external hard drive installs (because these do not use flash storage), but that's not what I will discuss in this tutorial anyway, as I find USB flash drives much more convenient than external hard drives. You probably won't need all that space anyway. If you do, sorry, wrong tutorial :)

* An OS to install on the flash drive. I'll come back to this in a moment.

* CD burning software capable of writing ISOs. You will need this for creating a LiveCD. I'll come back to this too.

* You may need software to partition the USB drive and make it bootable, though some installers do this for you. Most Linux distros come with cfdisk(cfdisk - Wikipedia), or at least fdisk, which will do fine. The official GNOME partition tool GParted (GParted - Wikipedia) is a very user friendly alternative. I will go through this in more detail later.

* A computer able to boot from USB. Now, this is of course a drawback of LiveUSBs. Not all computers are able to do this, and even if they are it can be a hassle to get it to recognize yours. That being said, most - if not all - computers made within the last 5-8 years should support it, and there are tools (like the PLoP Bootmanager - see PLoP - Bootmanager) to help booting from USB even if the BIOS does not seem to allow such a thing.

* Some technical knowledge, general intelligence, patience and a full backup wouldn't hurt either...


Choosing your OS

Well, if you were thinking about a full Windows Vista install, just forget it. Heh. Of course there is the space issue, but more important is the speed issue. We're running from a USB drive, remember, and that means disk operations will be quite a lot slower than usual. If you must have Windows, you should look into Windows PE (Windows Preinstallation Environment - Wikipedia). If you are intending to use this USB drive as a system rescue tool, a version of Windows could come in handy, but I would then consider creating a multiboot USB drive. Yep, that can be done too, but it's beyond the scope of this tutorial.

If you plan on using it for a portable workstation, looking into Linux is a good idea. There are many "minimal" (and not so minimal) Linux distros that are well suited for booting from USB. I tried 4 (or actually just 3...) of them before choosing one.

The first one I tried is called Puppy Linux. Cute, eh? It is one of the minimal distributions. Actually, if the computer it is running on has more than 64MB (or up to 256MB, depending on the version) of RAM, the whole OS will run in RAM. This, of course, makes it very fast and responsive - much more than a normal hard drive install of e.g. Windows XP. The whole OS is usually less than 100MB big. The exact size varies depending on version. When I add that it is famous for its good hardware detection, easiness of installing to USB drives, and that it comes with several full-blown applications like AbiWord and Mozilla Firefox, you might understand why I wanted to try this one.

Additional info on Puppy Linux:

Home Page | Puppy Linux
Puppy Linux - Wikipedia

Screenshots:
http://maketecheasie...-screenshot.jpg

But, I didn't really like it. It was not my kind of OS, really. It was, however, extremely easy to use, with nice GUI tools and everything, so for the Linux newbie - this is an excellent choice! With this one, one can get a nice working system up and running in no time, allowing a newcomer to concentrate on getting familiar with the Linux way of doing things. Basically, if you are new to Linux (or have never even tried it) and want one of these LiveUSBs - go for this one!

So, moving on in the diverse forest of Linux distros I chose to try out a classic. That is, a classic in the LiveUSB world. This one is very much used for this kind of things because of its small size. It's called D*mn Small Linux - (usually just DSL). The whole system in less than 50MB. Now that's one small Linux! Like Puppy, it runs totally in RAM. The system requirements are really low, which is why this distro is often used for "reviving" old computers.

Additional info on DSL:

(heh - you will have to copy/paste links and replace the **** because of the censoring)
http://www.****smalllinux.org/
http://en.wikipedia.org/wiki/****_Small_Linux

Screenshots:
http://www.openaddic...12-20.27.12.png
http://atomicmanifes.../12/dsl-42x.jpg

I played around with this one for a while. I have to say that it's a bit more my style than Puppy, but it had a few drawbacks that made me pick a different one. Like the kernel version. With so many distros availible I decided that it wouldn't hurt to try out a few more to see if I liked them better. DSL is a fairly nice distro though, and many LiveUSB users will undoubtly pick this one. It is quite user friendly, though nothing compared to Puppy. Linux newbies might benefit from looking elsewhere, depending on their patience and knowledge of computers in general.

So, after throwing away DSL for a while, I found an interesting looking distribution named SliTaz. It is the smallest one of the distributions I have mentioned so far, the ISO image being only about 25-30MB. Unlike DSL, it used the 2.6.x kernel, and included some quite impressing applications. Of course, this one also runs in RAM. It is apparently easy to set up for LiveUSB usage.

Additional info on SliTaz:

SliTaz GNU/Linux - Main page
SliTaz GNU/Linux - Wikipedia

Screenshots:
http://news.softpedi...w-large_006.jpg
http://3.bp.blogspot...litaz-linux.png

The thing is, I never got to actually try this one, as the LiveCD refused to boot... -_- Apparently this happens to some people, and there is no known way to fix it. When I get my new laptop I'll try to get it running on that one. In the meantime, I advise you to give it a try, as it looked quite promising!

Now, I moved away from the minimal distros and went for a "proper" Linux distro - Arch Linux. Arch is a build-from-scratch distro, much like Gentoo, but with binaries. And the install process is much faster... :) The idea is that when Arch is installed, you sit there with a base system and a command prompt, and basically have to add anything else that you want yourself. This is in other words not a suitable distro for total newbies, but should be fine for a bootable USB! Arch is optimized for i686 (and x86-64) processors, and is therefore fast on modern hardware. The drawback is that it does not support any other processor architectures. This means you need a Pentium II or higher, Athlon/Duron, etc. The AMD K6, for instance, will not work. This is not an issue for me, but you better find out whether or not it is an issue for you if you are thinking about going for this one.

Additional info on Arch:

Arch Linux - Home Page
Arch Linux - Wikipedia

Screenshots:
http://www.tuxradar....own.arch_01.jpg
http://upload.wikime...beryl-sshot.png
http://downloadsourc...6011d01dd88.jpg
http://fc09.devianta..._n_to_infty.jpg
http://img91.imagesh...creenshot2n.jpg

I decided to stay with Arch. It is exactly the kind of OS I like (I want control, thank you). It does not run in RAM like the others, but it is more than fast enough. The installation process is quite simple (though maybe not for a newbie), and well documented. The Wiki (ArchWiki) is a great place to start when starting out with Arch.

Now I have walked you through the distros I tried, but they are not the only options. Some other popular LiveUSB OSs include:

* Feather Linux - much like DSL, though larger, including more applications. 2.4.x kernel. Last release in 2005, now dormant.

* Xubuntu - A "lighter" Ubuntu with Xfce as window manager. Still considered a bit heavy for LiveUSBs, but runs fine on modern hardware.

* Gentoo - Very fun to install - often takes 3 or more days, at least 1, depending on experience and internet connection.. :P Not for a linux newbie. Compile (almost) everything from scratch. Time consuming, but gives (if you do it right) a highly customized and optimized system.

The Wikipedia article on LiveUSBs I mentioned earlier lists some more distributions.

Live USB - Wikipedia


Installing the OS

Now, hopefully, you have done your research and figured out what OS to install. You have also got a USB drive ready, and your fingers are itching to combine those two into a pocket-atomic-bomb. And we will.

The install process will naturally depend on which OS you choose. I will here go through the processes of installing Puppy, DSL and Arch. Mostly Puppy, because that is the best choice for newbies (and pros won't need so much guidance). If you chose a different OS you will have to do some research on your own, but reading the below won't hurt.


Disclaimer: If you mess up your computer in any way - it's not my fault. Do backups.


Puppy Linux:

So, going for a walk with Puppy are we? :P This is really simple, so don't worry at all. The first thing you want to do is to get a Puppy LiveCD. How? Download the ISO from Downloads | Puppy Linux - you want the latest production version. It should be around 100MB. After you have finished downloading, burn the ISO to an empty CD. There are numerous tools for doing this. I used the extremely simple tool BurnCDCC under Windows (BurnCDCC - Download). Under Linux you could use e.g. Nero Linux. Your choice, really.

So, got a LiveCD? Reboot your computer, and get it into BIOS (or the boot menu, if you have that) to make your computer boot from the CD. When the CD boots you will have to choose a few things like keyboard layout and screen resolution. Fairly straightforward. You should soon be inside a working Puppy Linux. Feel free to look around a bit and get familiar with it.

[ATTACH]1847[/ATTACH]

When you decide it's time to install Puppy to your USB drive, plug it in. You should see some semi-transparent gray icons in the bottom left corner of your desktop, above the MENU button (see screenshot). These are the mountable devices. The icons can be dragged around. By clicking one, Puppy will automatically mount it. To unmount it, right click it and choose "Unmount (if mounted)" or something like that. For more information about mounting, you could read this short article: How to mount partitions and filesystems in Linux. The article also explains mounting and unmounting from a command line. You do not have to worry about that in Puppy, though.

So, you have spotted your USB drive, right? What its name is will depend on things like how many harddrives your computer has, if there are other USB drives inserted and so on. With one harddrive and no other USB drives installed, it is probably named "sdb1". If you have two hard drives installed, "sdc1". The number after the letters represent the partition. So if you have one hard drive - "sda" - with two partitions, the first partition will be called "sda1", the second "sda2". Your flash drive is probably not partitioned (yet), so it will only have one partition - "sdb1" (or "sda1", "sdc1", "sdd1" etc.) If you are normally a Windows user (and new to Linux), this can be a bit confusing. Read page 1, 2 and 3 in this article: Linux Partitions: A Primer Page 4 deals with setting up partitions, but it does not really apply to USB drives.

Before we can proceed with installing Puppy to the USB drive, we want to partition it, and make one partition (the one we will install to) bootable. Puppy includes a user friendly tool for this - GParted. Click the MENU button on your desktop (or right click on the desktop) - choose "System" - then "GParted partition manager". If you read the article above, you should know what a partition is. If you read page 4 of it, forget what you read. :P When we are dealing with partitioning a USB flash drive, there are a few things to consider - mainly: Do you want to be able to read it from Windows?

Windows only recognizes the first partition of a USB drive. And it does not understand the Linux filesystems (like ext2, ext3). I want to be able to use my LiveUSB drive like a normal USB drive. Therefore, I make the first partition of the USB drive about 1GB in size (I have 8GB in total), with the filesystem FAT32 (which is recognized by Windows as well as Linux). I will not have my OS installed on this partition, it will only serve as a "bridge" between Windows and Linux. Now, when I put the USB drive in - Windows thinks it's a 1GB big USB drive. The rest of the drive is not reachable through Windows by default. I can place files on that partition through Windows, like I would on any USB drive. I find that useful.

NOTE: Before continuing - 1) Make sure that you are partitioning your USB drive and not your harddrive... 2) Expect all data on your USB drive to be lost.

In order to install Puppy (or any other OS), one partition must be bootable. That is done in GParted by first partitioning the drive, then right-clicking the partition and choose "Manage flags" (or something like that). Set the bootable flag for the partition you intend to install Puppy to. I recommend setting the filesystem to "ext2" for the partition where you will install Puppy to, as "ext3" will wear out your drive faster.

You might want to have more than 2 partitions, like one separate partition for your /home directory, and/or one separate partition for backups. This is up to you. The only thing I want to mention is that creating a swap partition is usually not a good idea, as that will wear out your drive faster.

Hopefully by now you will have your flash drive properly partitioned, with one (only one) partition bootable. If you feel unsure about this, doing some research on Linux partitions and filesystems could be a good idea. A comprehensive tutorial on GParted can be found here: GParted partitioning software - Full tutorial

Now that your drive is ready, we will install Puppy to it. This is very easy through the Universal Installer, found under MENU -> "Setup" -> "Puppy universal installer". Click it.

The instructions are simple and easy to follow, so do just that. Make sure that you are installing to your flash drive, not your hard drive. Install to the partition you made bootable.

When choosing MBR, the default should do. If you are having problems booting (and the troubleshooting part of this tutorial can not help you) - try experimenting with reinstalling with a different MBR.

After the installer has finished - congratulations, you have a LiveUSB with Puppy Linux! Shut down the LiveCD (it will ask you if you want to save settings and stuff, you probably don't want that) - and reboot. Go into the BIOS (or boot menu) to boot from USB. Remove your LiveCD (so that you don't get tricked into thinking it booted from USB when it actually used your LiveCD), and go ahead. Hopefully it should boot without problems. If you do experience problems, see the troubleshooting section below.

Good luck with Puppy Linux on a stick!


D*mn Small Linux (DSL):

This section will not be as spoonfeeding as the previous one on the Puppy install, so if you are a newcomer to Linux (but wants DSL, not Puppy), you might want to read that one before reading this.

There are many ways to install DSL. If you intend to partition your drive like I suggested in the section about Puppy (the first one FAT32 for normal USB drive usage, the second ext2 bootable for the OS - possibly more partitions for /home etc.) you will want to use GRUB as your bootloader, as Syslinux accepts FAT16 or FAT32 only.

Anyway, the process is quite d*mn simple :P Get the files onto the drive and install a bootloader. See this page for the details:

Note: You will have to copy/paste the links - and replace the **** because of the censoring.

http://www.****smalllinux.org/wiki/index.php/Install_to_USB_From_within_Linux

The LiveCD includes a script to install DSL to USB drive which makes life easier for you. See this page:

http://www.****smalllinux.org/wiki/index.php/Install_to_USB_From_within_DSL

You might benefit from reading this page first, which also includes links to instructions on installing from Windows or Mac OS:

http://www.****smalllinux.org/wiki/index.php/Installing_to_a_USB_Flash_Drive

You might also want to look around in the Wiki:

http://www.****smalllinux.org/wiki/index.php/Main_Page

- and in particular the FAQ:

http://www.****smalllinux.org/wiki/index.php/Frequently_Asked_Questions

Because these resources basically explains everything, I will not write more on this. Good luck with DSL!


Arch Linux:

If you're going for Arch, you're hopefully not a newbie, so no spoonfeeding. For advice on partitioning a USB drive, see the Puppy section.

The Arch Wiki is an invaluable resource, so if you have questions, make sure to check it out: ArchWiki

This is the document you want to read for installing Arch:
Official Arch Linux Install Guide - ArchWiki

Or - if you are new to Arch this document might be a better idea:
Beginners Guide - ArchWiki

To get Arch on a USB drive, basically just install it as you normally would (to a hard drive), but pick the USB drive as destination instead. The Arch installer will walk you through partitioning (or, more accurately, partitioning is an option in the install menu...) Auto partitioning is not a good idea. Again, see the Puppy section for details on partitioning a USB drive.

When your USB drive is partitioned and bootable, just proceed with the installation until you reach the configuration part. There are a few things there that might need some clarification.

This article should give you an idea.
Installing Arch Linux on a USB key - ArchWiki

1) If you are going to move the USB drive around (between different computers), it's best to use UUIDs in menu.lst and fstab
2) In mkinitcpio.conf - make sure to add usb to the hook list (if it's not there already)

Using the above sources, installing Arch should be easy. When installing is finished, reboot from USB and take a good look at your fresh, modern, appealing... command prompt. :confused: No fancy GUI before you've added it yourself. That's the Arch way! You might benefit from configuring your network first, by the way. A good WM for USB Arch would be Openbox, but I'm sure you would like to figure out that by yourself :)

Here are some tips after installing:
Post Installation Tips - ArchWiki

So, congratulations with your new Arch LiveUSB!


:cursing: Troubleshooting :cursing:

There are a lot of things that might go wrong, and here are some common issues you might face:

1. I can't get into this BIOS thing!

You might want to read BIOS - Wikipedia, How to Change the Boot Order in BIOS and Getting Into The BIOS


2. I'm unable to choose booting from USB drive in BIOS.

Well, first of all, make sure you have plugged the USB drive into one of the USB ports installed on your motherboard. Not in a hub, not in an extra USB card, but directly into one of the ports on the motherboard. If the BIOS still doesn't recognize it, it is possible that your computer does not support booting from USB. Try plugging it into a few different computers. If they do not recognize it either, chances are that you've done something wrong with the USB drive. Remembered to make it bootable? If they do recognize it, meaning that your computer does not support booting from USB, you might want to use something like the PLoP bootmanager I mentioned earlier in this tutorial. See PLoP - Bootmanager.


3. BIOS gives me several options from booting from USB, like USB Zip, USB FDD and USB HDD - which one should I choose?

Come on, try them all. :P Seriously, though, USB HDD is usually the preferred one, USB Zip might work. USB FDD is best avoided. The USB Zip option is typically used on older systems that do not support USB HDD boot. Using this boot option might require modifying the drive geometry to match how the BIOS has been hard-coded to see the device. Go figure.


4. Ok, my computer recognized the USB drive, but it won't boot my OS - just gives me errors.

You made a mistake. If you think the install is fine, make sure that the bootloader is configured properly. An example: You're using the GRUB bootloader, and get an error 15: File not found. This is quite common. The reason is probably that the GRUB configuration file (/boot/grub/menu.lst) is not set up properly. Google will help you here.


5. It boots, and seems to run fine, but my settings are not stored!

Depending on the OS installed, you might have to configure this yourself. DSL, for instance, has a file where all directories/files to be stored are listed. You will need to do some research on your own here.


7. I have a problem not listed above..

First - use Google to see if it is a common problem with a simple (or not so simple) solution. If that is not the case, you can post it in this thread or in the forum for the OS you installed (if it has one). If everything fails, go emo.


8. It works! :w00t:

Good job! Cool, eh? You deserve a cookie :)


At last

What now? You've got a LiveUSB up and running, which basically means that you can take your system around wherever you want, plug it in, and go wild. You decide what to make of it. A system rescue tool? A hacking tool? A portable workstation? It is your choice. Anyway, I hope this tutorial was helpful to you! Have fun with your stick! :D

Attached Thumbnails

  • screenie - mnt icons.jpg

  • 3


#474499 Basic Norwegian: marwex89

Posted by marwex89 on 18 June 2009 - 03:54 PM

Basic Norwegian: marwex89

"Grunnleggende norsk: marwex89"

So, this is a "tutorial response" to SweeD's tutorial on basic swedish (http://forum.codecal...dish-sweed.html). I have even officially asked Jordan (yeah the Admin himself) if he thought it was OK to post tutorials covering human languages - not only programming languages. He didn't just say: "OK" - no, he even went as far as saying that: "Being a forum with members from all around the world it could possibly help us understand one another better." Yup.

So let's go on, people: Norwegian. As you might know, I am a native speaker of this fantastic language, and I will try to learn you some useful(?) things about it. A note: I will not talk about Sami - the language of the Sami. The Sami are the indigenous people of Norway, but their language is very different to Norwegian (more similar to Finnish).

Now, first of all, you should know that there are two - 2 - different written norms of Norwegian. One is called Bokmål (literally: book-language), the other is called Nynorsk (literally: new-Norwegian). To explain this, I'll have to dive into Norwegian history - well, much like in school.

Bokmål is, we can say, a "norwegianization" of Danish. As you might (not) know, Denmark officially ruled Norway for 400 years (until 1814). Then, the "upper class" in Norway (educated, rich and cool people) wrote Danish, and spoke something somewhat similar to Danish. After we got away from Denmark (just to be given away to Sweden :glare: - but that's another story), we wanted our own written language, and Bokmål was born. Of course, today's modern Bokmål is quite different from Danish. But the similarities are present, and most norwegians can therefore understand written Danish.

So to Nynorsk. Well, this is what you get when one man (Ivar Aasen) goes jogging around in Norway, picks up what he believes are the best parts from a number of dialects, and creates a language from that. The result is fine, though pretty different from Bokmål. Nynorsk has, of course, also been modernized a lot, and Bokmål and Nynorsk keep becoming more similar (because both are continually edited relative to how we actually speak).

When we go to school, we can choose between Nynorsk or Bokmål as our main written language (more or less dependent on how we speak). This is (for example) the one we will use for most tests. The majority of people pick Bokmål. Nynorsk is mainly used in the west. We do have to learn both, however, but focuses on one.

So, a quick note about dialects. In Norway, a guy from Oslo is not necessarily going to understand a guy from some rural area in the west. The guy from the west will however probably understand the guy from Oslo, because we hear the Oslo dialect all the time, on TV, for instance. The Oslo dialect is also quite close to Bokmål, while some dialects really aren't close to anything... :blink: Bottom line: Norwegian dialects are very different, and can differ greatly locally as well.

Enough history, let's learn some hard facts.

First of all, the alphabet. I believe it is unique, but not very different from the English. In fact, it is exactly the same, but with three additional vowels at the end: Æ, Ø, and Å. So the alphabet looks like this:

Aa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy Zz Ææ Øø Åå



Chapter One: (Kapittel en)
- Basic Norwegian Phrases You Must Know

ENGLISH = BOKMÅL (NYNORSK)
Hello, I am a tourist. = Hei, jeg er turist. (Hei, eg er turist.)
I don't understand you... = Jeg forstår deg ikke... (Eg forstår deg ikkje...)
Got drugs? = Har du dop? (Har du dop?)
Can I have a beer, please? = Kan jeg få en øl?* (Kan eg få ein øl?)
Can I borrow this gun?** = Kan jeg låne dette geværet? (Kan eg låne dette geværet?)
Do you speak english? = Snakker du engelsk? (Snakkar du engelsk?)


*Note: Norwegians are not as polite as other people. We don't usually say "please" when asking for a beer.

**Note: Gun in English can mean pistol as well as larger firearms, like shotguns. The Norwegian word "gevær" (which I traslated with) can not mean pistol, only larger firearms, like shotguns and rifles. To avoid confusion, don't use a pistol in Norway. :cool:




Chapter Two: (Kapittel to)

- Norwegian Phrases You Should Know

ENGLISH = BOKMÅL (NYNORSK)

Where is the nearest toilet = Hvor er nærmeste toalett? (Kvar er næraste toalett?)
Police! = Politi!* (Politi!)
Fire! = Brann! (Brann!)
Call an ambulance! = Ring etter ambulanse! (Ring etter ambulanse!)
Darn, I hate cell phones. = Pokker, jeg hater mobiltelefoner. (Pokker, eg hatar mobiltelefonar.)
What's wrong with your hair? = Hva er galt med håret ditt? (Kva er gale med håret ditt?)


*Note: Emergency number is 110 for fire, 112 for police, and 113 for ambulance. Don't ask what happened to 111, I do not know.



Chapter Three: (Kapittel tre)
- The MSN conversation

ENGLISH = BOKMÅL (NYNORSK)
Hi! = Hei! (Hei!)
Bye! = Ha det! (Ha det!)
How old is your sister? = Hvor gammel er søsteren din? (Kor gamal er søstera di?)
I love you = Jeg elsker deg (Eg elskar deg)
How are you? = Hvordan går det? (Korleis går det?)
Thanks, fine, you? = Takk, bra, du? (Takk, bra, du?)
Good = Bra (Bra)
Splendid = Utmerket (Utmerka)
Very = Svært (Særs)
See you later! = Ser deg senere! (Ser deg seinare!)
Yes = Ja (Ja)
No = Nei (Nei)
Maybe = Kanskje (Kanskje)
Anything else? = Noe annet? (Noko anna?)
OK = OK (OK)
Sorry = Beklager (Orsak)*
I am a nice cat. = Jeg er en snill pus. (Eg er ein snill pus.)


*Note: If you actually say "Orsak" on the street, expect people to LOL :lol: It's never used, rarely even in written text, but it's funny ;)



Chapter Four: (Kapittel fire)
- Lines to get some chicks

"Your eyes are blue as the water in my toilet..." (I learnt this one from a girl from Kosovo... Works great!) = "Øynene dine er blå som vannet i toalettet mitt..." (Nynorsk: "Auga dine er blå som vatnet i toalettet mitt...") - Very romantic. :001_tt1:

"Can't we just go home and scr*w?" (Why make it complicated?) "Kan vi ikke bare gå hjem og **?" (Nynorsk: "Kan vi ikkje berre gå heim og **?") :blink:

"Come to me, little girl, I got cookies..." (Note: Make sure there is no police around before trying this...) = "Kom til meg, lille jente, jeg har kjeks...." (Nynorsk: "Kom til meg, vesle jente, eg har kjeks...")



Chapter Five: (Kapittel fem)
- Learn to count

We will now learn to count!

0: null
1: en (Note: In Nynorsk = "ein")
2: to
3: tre
4: fire
5: fem
6: seks (Note: no, not **, like in Swedish.. We are not that funny, I'm afraid..)
7: sju
8: åtte
9: ni
10: ti

More than 10 = many = "mange".

That will do, I think. If you encounter problems, ask for paper & pen ("Can I have paper & pen, please? I do not know how to say that number." = "Kan jeg få papir og penn? Jeg vet ikke hvordan jeg sier det tallet." (Nynorsk: "Kan eg få penn og papir? Eg veit ikkje korleis eg seier det talet.")).

Or send me an email, and I'll try to answer within a week or five.



Chapter Six (Kapittel seks)
- Closing words

So, this brief tutorial has come to an end. :crying: But, feel free to ask any questions/translations/whatever-Norway-related in this thread, I'll be glad to help/enlighten/bore you. So long, dudez. :P
  • 3


#474251 A very beginner question (How do you do..stuff?)

Posted by marwex89 on 18 June 2009 - 06:46 AM

Well, you could start by looking into GUI programming, in other words creating a user interface - instead of using the console. This is platform dependant, i.e. doing it for Windows will be different from Linux.

Then, you could dive into using USB, video libraries, what not.. For "real" software it's often about using some kind of library/libraries.

Then there is the internet part: sockets, TCP/IP etc etc. A world of itself, really. Again, platform dependant.

Anyway, it's a lot to learn. Good luck ;)

Posted via CodeCall Mobile
  • -1


#472964 Function Pointers

Posted by marwex89 on 14 June 2009 - 06:40 PM

C++ Function Pointers

Now, as C++ programmers, we love writing messy, unreadable and advanced-looking code that will leave beginners head-scratching for hours. Function pointers happens to be a great tool for achieving maximum confusion and frustration. Did I mention that they are actually useful too?

So, what on earth is a function pointer? Function pointers are simply pointers that point to functions, or to be more specific, function addresses. Let us take a few seconds and just think about that. Done? Then we will move on. Function pointers can be very useful, and very elegant, as we will see, but their syntax is quite awkward and messy. Let us take a look at one simple function pointer right here:

int (*pMyFuncPointer) (char, int);

pMyFuncPointer is our function pointer. Kind of like normal pointers - who point to a specific datatype - function pointers point to specific function signatures. In this case, we have a pointer which is able to point to any function taking a char and an int as arguments, and returns an int.

Let's see our pointer in action, shall we?

#include <iostream>

int Foo(char, int); // First we need a function with matching signature
int (*pMyFuncPointer) (char, int) = &Foo; // We declare our function pointer, and initializes it to point at Foo. 
                                          // The reference operator can usually be omitted, but to write portable code, 
                                          // leave it there. It's also a bit clearer, IMO

int main()
{
	(*pMyFuncPointer)('d', 9); // Calls Foo.
	pMyFuncPointer('d', 9); // Also calls Foo
		
	system("PAUSE");	
	return 0;
}

int Foo(char c, int i)
{
	std::cout << "I'm Foo. It's a funny name" << 
       "\nVariable c: " << c << "\nVariable i: " << i << std::endl;
	return 0;
}

This program uses the function pointer pMyFuncPointer to call the function Foo, which prints some text together with its arguments. Are you still with me?

Ok, so function pointers can be used to call functions. There is a lot more to it, but before we go any further, I would like to show you a few other types of function pointers. The previous example would work in C, except from the std::cout part, but the example below includes classes, and is limited to C++ programmers:

#include <iostream>

class FooClass
{
public:
       void Foo1(int i) {std::cout << "Foo1's integer: " << i << std::endl;} 
       void FooConst(int i) const {std::cout << "FooConst's integer: " << i << std::endl;}
};

int main()
{
    /* ASSIGNING TO CLASS MEMBER FUNCTIONS */
    void (FooClass::*pFoo)(int) = NULL;
    void (FooClass::*pFooConst)(int) const = NULL;        
    
    pFoo = &FooClass::Foo1;             
    pFooConst = &FooClass::FooConst;    
        
    /* CALLING CLASS MEMBER FUNCTIONS */
    FooClass instance1;       
    (instance1.*pFoo)(67);        
    (instance1.*pFooConst)(57);
       
    FooClass* instance2 = new FooClass;  
    (instance2->*pFoo)(47);       
    (instance2->*pFooConst)(37);               
    delete instance2;	
    
    system("PAUSE");	
    return 0;
}

The example basically shows how to assign a pointer to a class member function, here in two steps (initializing to NULL, then assigning), and how to call these functions.

It is time to move on a bit. To begin with, function pointers can be compared, like other variables. Have a look at this:

#include <iostream>

void (*pFoo)(void) = NULL;

void Foo(void)
{
    pFoo = &Foo;    
}

int main()
{
    Foo();
    
    if(pFoo == &Foo) // Comparison of a function pointer and a function address
        std::cout << "You **, you changed my variable!" << std::endl;    
        
    system("PAUSE");	
    return 0;
}

You can also do comparisons like

if(pFoo != NULL)
	// ...

Now we will look at how one can pass function pointers as arguments to a function. Here is a classic example:

#include <iostream>

float Divide(float num1, float num2) {return num1 / num2;}
float Multiply(float num1, float num2) {return num1 * num2;}
float Minus(float num1, float num2) {return num1 - num2;}
float Plus(float num1, float num2) {return num1 + num2;}

float Calc(float num1, float num2, float (*pCalcMethod)(float, float))
{
    return pCalcMethod(num1, num2);
}

int main()
{
    float result = Calc(50, 25, &Plus);
    //float result = Calc(50, 25, &Minus);
    //float result = Calc(50, 2, &Multiply);
    //float result = Calc(50, 2, &Divide);

    std::cout << "Result: " << result << std::endl;
    system("PAUSE");	
    return 0;
}

When we call Calc, we specify (using function pointers) what kind of operation we want to perform on the numbers. Notice how one declares a function pointer as an argument (not very surprising, really).

float Calc(float num1, float num2, float (*pCalcMethod)(float, float))
 // ...

The function Calc accepts two floats, and a pointer to a function which accepts two floats, and returns a float.

We keep moving, this time to returning function pointers from functions. And this is a true mess. Check it out:

#include <iostream>

float Multiply(float num1, float num2) {return num1 * num2;} 
float (*GetFPointer(void))(float, float) {return &Multiply;}

int main()
{
    float (*pMultFunc)(float, float) = GetFPointer();
    
    float result = pMultFunc(2, 5);
    
    std::cout << "Result: " << result << std::endl;
	
    system("PAUSE");	
    return 0;
}

This is the tough one, right?

float (*GetFPointer(void))(float, float)
 // ...

It means that GetFPointer is a function which takes a void (i.e. nothing), and returns a pointer to a function which takes two floats and returns a float. Because of the messy syntax, this is usually simplified through an innocent typedef.

#include <iostream>

typedef float(*pFunc)(float, float);

float Multiply(float num1, float num2) {return num1 * num2;} 
pFunc GetFPointer(void) {return &Multiply;}

int main()
{
    float (*pMultFunc)(float, float) = GetFPointer();
    
    float result = pMultFunc(2, 5);
    
    std::cout << "Result: " << result << std::endl;
	
    system("PAUSE");	
    return 0;
}

Because of this typedef:

typedef float(*pFunc)(float, float);

There is now a type (pFunc) which declares a pointer to a function that takes two floats and returns a float. Exactly what we need. We can even use it to declare our function pointer in main:

Instead of:

float (*pMultFunc)(float, float) = GetFPointer();

We can write:

pFunc pMultFunc = GetFPointer();

Not as messy, fun and confusing, but it does the job.

Now, to another subject: Arrays of function pointers. These were really useful in C. While our fancy C++ classes were not around, old C-structs could still contain arrays of function pointers. Don't laugh. These arrays are very useful, or at least cool.

#include <iostream>

float Plus(float num1, float num2) {return num1 + num2;}
float Minus(float num1, float num2) {return num1 - num2;}
float Multiply(float num1, float num2) {return num1 * num2;}
float Divide(float num1, float num2) {return num1 / num2;}

float Calc(float num1, float num2, float (*pCalcMethod)(float, float))
{
    return pCalcMethod(num1, num2);
}

int main()
{
    float (*pFoo[])(float, float) = {&Plus, &Minus, &Multiply, &Divide};    
    
    float result;
    
    for(int i = 0; i < 4; ++i)
    {
        result = Calc(10, 2, pFoo[i]);
        std::cout << "Result: " << result << std::endl;
    }
	
    system("PAUSE");	
    return 0;
}

The above program illustrates the concept. Actually, it just modifies our calc-program from earlier. Now, we run through the different calculations using an array of function pointers:

float (*pFoo[])(float, float) = {...};

The braces after *pFoo tells us: "Hey! It's an array!" The size is determined from the number of initializing elements in the following curly braces "{...}", just like a normal array. We can also write e.g.

float (*pFoo[10])(float, float);

Thus declaring an array of 10 function pointers.

Array declarations like this are - by the way - often made simpler by the use of a typedef:

#include <iostream>

[B]typedef float(*pFooType)(float, float);[/B]

float Plus(float num1, float num2) {return num1 + num2;}
float Minus(float num1, float num2) {return num1 - num2;}
float Multiply(float num1, float num2) {return num1 * num2;}
float Divide(float num1, float num2) {return num1 / num2;}

float Calc(float num1, float num2, float (*pCalcMethod)(float, float))
{
    return pCalcMethod(num1, num2);
}

int main()
{
    [B]pFooType pFoo[] = {&Plus, &Minus, &Multiply, &Divide}; // Made simpler using typedef[/B]
    
    float result;
    
    for(int i = 0; i < 4; ++i)
    {
        result = Calc(10, 2, pFoo[i]);
        std::cout << "Result: " << result << std::endl;
    }
	
    system("PAUSE");	
    return 0;
}

Now, guys, this is the last thing I want to show you. It is pretty close to a C++ syntax nightmare (I did that on purpose), but it should sum up what we have been through so far. The source file for this program (the one below) can be downloaded below.

/* 
    
    Program:        FunctionPointersTestStuff
    Program type:   Useless
    Copyright:      marwex89 - www.codecall.net
    
    This program defines a class which uses a vector to store function pointers. 
    The program adds function pointers to this vector through the use of function pointers,
    and later retrieves them (using function pointers) and calls the functions they point to.
    
*/

#include <iostream>
#include <sstream>
#include <vector>

// Useless function for adding two characters into a string, and add the number 2
const std::string AddToStr_1(char a, char b) 
{
    std::ostringstream oss;
    oss << a << b << 1;
    return oss.str();     
}

// Useless function for adding two characters into a string, and add the number 2
const std::string AddToStr_2(char a, char b) 
{
    std::ostringstream oss;
    oss << a << b << 2;
    return oss.str();
}

// Useless function for adding two characters into a string, and add the number 3
const std::string AddToStr_3(char a, char b) 
{
    std::ostringstream oss;
    oss << a << b << 3;
    return oss.str();
}

// Useless function for adding two characters into a string, and add the number 4
const std::string AddToStr_4(char a, char b) 
{
    std::ostringstream oss;
    oss << a << b << 4;
    return oss.str();
}

// Useless function for adding two characters into a string, and add the number 5
const std::string AddToStr_5(char a, char b) 
{
    std::ostringstream oss;
    oss << a << b << 5;
    return oss.str();
}

// Useless class for storing function pointers
class CFuncPointerStorage
{   
private:
    
    std::vector<const std::string(*)(char, char)> vec;
        
public:
        
    const std::string(*GetFunctionPointer(unsigned int index))(char, char) const
    {
        if(index <= vec.size())
            return vec[index];
        else
        {
            std::cerr << "Weird error occured, you need a new computer." << std::endl;
            return NULL;
        }
    } 
    
    void SetFunctionPointer(const std::string(*pFunctionPointer)(char, char), unsigned int index)
    {
        if(index < vec.size())
            vec[index] = pFunctionPointer;
        else
            vec.push_back(pFunctionPointer);
    }           
};

// Using the stuff
int main()
{
    CFuncPointerStorage* fpStorage = new CFuncPointerStorage;
    
    // Put function pointers into storage object
    const std::string(*fpArray[])(char, char) = {&AddToStr_1, &AddToStr_2, &AddToStr_3, &AddToStr_4, &AddToStr_5};    
    for(int i = 0; i < 5; ++i)
        fpStorage->SetFunctionPointer(fpArray[i], i);
    
    // Get them back and perform calls
    for(int i = 0; i < 5; ++i) 
        std::cout << (*(fpStorage->GetFunctionPointer(i)))('I', 'T') << std::endl;
    
    delete fpStorage;
    	
    system("PAUSE");	
    return 0;
}

Well, my friends, that was it. I have attached the code for the last program (the one above). Hopefully you found this tutorial helpful - feel free to comment and +rep - I appreciate it. See you later ;)

[ATTACH]1655[/ATTACH]

Attached Files

  • Attached File  main.cpp   2.86KB   380 downloads

  • 6


#395142 Next?

Posted by marwex89 on 13 October 2008 - 11:48 AM

I like the last one, but after all the poor thread starter will have to read through quite some off-topic ****, and we better not make it worse for him, eh?
  • 1


#386663 C++ OOP Newbie Problems

Posted by marwex89 on 27 September 2008 - 04:31 PM

Ok, solved :D
I put this code into NetBeans (another IDE, great btw) to sort out this stuff.

1) It should be "char limit_x = 'h';"
2) It shouldn't at all, because you can't initialize class variables like that :P Make a constructor and put it there....
3) Your functions definitions are put inside the class definition. Put them outside..

When I corrected this, I got one error: basically "variable a undeclared", so I made one, as an int.

The result:
//--------------------

class Chess_Piece
{
public:
    char inf_x[27];
    int inf_y[27];
    
    char limit_x;
    int limit_y;
    
    Chess_Piece(void); // Constructor
    int rook_inf(const char x_pos, const int y_pos); // Declaration only
    int add_influenced(char y_pos, int x_pos); // Declaration only
};


// CONSTRUCTOR
Chess_Piece::Chess_Piece()
{
    limit_x = 'h';
    limit_y = 8;
}

// Definition
int Chess_Piece::rook_inf(const char x_pos, const int y_pos)
{
    //14 influence squares rook
    //13 influence squares (bishop)
    //2 influence squares pawn
    //8 knight
    //8 king
    //27 queen
    
    //int inf_index = 0;
    //char temp_x = x_pos;
    //int temp_y = y_pos;
    
    //while (temp_x <= limit_x) {
    //y_pos;
    
    //    i++;
    //    inf_index++;
    //}
    return 0;
}

// Definition
int Chess_Piece::add_influenced(char y_pos, int x_pos)
{
    static int inf_index = 0;
    inf_y[inf_index] = y_pos;
    inf_x[inf_index] = x_pos;
    
    inf_index++;
}

//-------------------------------

int Main()
{
    int a = 1; // Made one :)
    
    Chess_Piece bishop;
    
    bishop.add_influenced(a, 1);
    bishop.add_influenced(a, 2);
    
    return 0;
}

Sorry I didn't see this at once, I should have done this before...
  • 2


#386543 Can someone point the mistake... C

Posted by marwex89 on 27 September 2008 - 01:03 PM

Yup :P
  • -1


#376946 CodeCall ideas

Posted by marwex89 on 26 August 2008 - 12:05 PM

Ok, I couldn't really find anywhere to post this so: A new thread is born! :D

I discussed this with Jordan, and he told me to make a post, so don't blame me... Ahem! :D

My (advertising) idea was to make an YouTube profile - named codecall, for example. Because YouTube is popular. And then post video tutorials, or whatever suitable... :) All vids should have a splash screen thing with The Logo and that excellent "while(true)" thing.

Other ideas could be posted below, I guess...
  • 2


#368095 Beyond Guru...

Posted by marwex89 on 28 July 2008 - 05:00 AM

[*sighs, looks at rep count*] Ahh.. Who needs rep anyway :(
  • 1


#366990 I know you love it

Posted by marwex89 on 24 July 2008 - 05:19 AM

rofl :D:D
(btw, isn't it Wiener?? Whatever :D)
  • 1


#366232 When did you start writing html?

Posted by marwex89 on 22 July 2008 - 09:20 AM

lol

OH, yeah, HTML... Right...
  • 1


#366017 Clear screen in windows console using API

Posted by marwex89 on 22 July 2008 - 05:09 AM

This is mosly useless, I'll admit it, but it's fun :D Perhaps you can learn something from it?

It's software (source and exe) for demonstrating how to clear the screen in the Windows console using Win32 API. It contains a few other things too, like some error handling demonstration and a function for wait (ms) using API.

Check it out, if you think you can learn something/use it for something.

NOTE: If you want to clear the screen without API, try
system("CLS");
But that's cheating, an no fun :D

It was tested on WinXP SP2.

Have fun

Attached Files


  • 1




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download