Drawing rectangles SDL
Drawing rectangles can become such a pain in the ass after drawing them a couple of times. I made a helper function that makes this easier.
void FillRect(int x, int y, int w, int h, int color) {
SDL_Rect rect = {x,y,w,h};
SDL_FillRect(screen, &rect, color);
}
I want to add a 100×150 rectangle at the position (25,25) with the color white.
FillRect(25,25,100,150,0xFFFFFF);
Great, no more headache and code memorizing.
Using the OpenBSD package system
The package system in OpenBSD consists of pre-compiled programs that can be managed with the pkg tool. The packages may not necessarily contain the same kind of security and realibility as the base system, but pkg is useful for installing “third party” software.
1. Create the environment variabel PKG_PATH with the value of the right directory to fetch the packages.
export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.5/packages/i386/
2. Add this line into the startup file, ~/.profiles so we don’t have to export it every time we use pkg.
Installing a package
pkg_add -i firefox
Removing a package
pkg_delete firefox
Information about installed packages
pkg_info
Mount ntfs drive on Linux
1. Install ntfs-3g.
2. Create a folder in /media or /mnt (mkdir /media/windows)
3. Use fdisk -l to get the name of the NTFS drive (example: dev/sda1)
4. Add the drive into /etc/fstab so it mounts automatically.
/etc/fstab
/dev/sda1 /media/windows ntfs-3g defaults 0 0
Using X with SSH
I was working on the school computers from home trough SSH and needed to use X. Using the “-X” parameter gave me error messages when I used the keyboard mouse if I remember correctly. This worked without any error messages though.
ssh -Y -l user server
Encrypting mail in Thunderbird using GnuPG and Enigmail
Thunderbird is a mail user agent developed by Mozilla. GnuPG is an encryption program (free software) that uses the standard OpenPGP. This standard is based on encryption using a private and public key. The private key is used to decrypt the data while the public key is used to encrypt the data.
The Thunderbird add-on Enigmail, provides an “back-end” interface to GnuPG so the user can use Thunderbird to encrypt/decrypt mail. After installing Enigmail, generate a keypair. This will create a public and private key for the current account. The public key is meant to be distributed so other people can send mail encrypted to you. The private key however, is important NOT to distribute. Since it is used to encrypt the messages sent to you with your public key. The public key is usually uploaded to a keyserver.
It’s possible to search for public keys on the keyservers and add public keys into a local list and configure Thunderbird to encrypt all messages by default (supposing the public key to the person in question is added into your key list). Both Thunderbird, GnuPG and Enigmail, are very useful indeed : )
For more information about GnuPG and Enigmail:
http://www.gnupg.org/
http://enigmail.mozdev.org/home/index.php
Compile SDL/OpenGL applications using g++
This is how I compile a C++ program with SDL and the OpenGL libraries GL and GLU.
g++ -o appname opengl.cpp `sdl-config –libs –cflags` -lGL -lGLU
sdl-config –libs –cflags is used to get the library path and include path for SDL. This can be used instead of manually specifying the libraries for SDL.
Burn DVD in Linux using dvd+rw-tools
Install dvd+rw-tools with your package manager or download it from here. And then invoke the following commands…
Format disc where /dev/dvd is the device name:
dvd+rw-format -force /dev/dvd
Burn the directory (/home/user/stuff) onto the DVD:
growisofs -Z /dev/dvd -R -J /home/user/stuff
More information:
http://fy.chalmers.se/~appro/linux/DVD+RW/
become anonymous on the internet using Tor
Tor is a platform independent program that protects you from traffic analysis. Traffic analysis is a form of surveillance of your network traffic which is a threat to your personal integrity. Tor is usually used to surf anonymously, but can also be used with for example instant-messaging applications.
How Tor works
When using Tor, your communication with the internet is protected by distributing it trough a network of different relays trough the world which are run by volunteers. The communication is also encrypted so no one can see what you’re doing or learn your location.
I recommend using the Firefox add-on Torbutton which provides an easy way to disable/enable Tor in Firefox. This way, you don’t have to configure your browser either.
Pitfalls with Tor
Watch out for cookies, flash files, java applets and similiar web applications. They can reveal your IP-address even if you use Tor. Using Add-ons for Mozilla Firefox like No Script and Flash Block can prevent this. Be sure that you don’t fall for things like this.
Even if Tor encrypts your traffic inside the Tor-network and makes you anonymous. The last relay you are connected to, which is directly communication with the webserver can still see your traffic. Don’t use Tor if you do things that can expose your identity, for example logging in to your webmail (if you truly want to be anonymous that is). Using an encrypted protocol like HTTPS prevents this though.
Read more about potential pitfalls here: http://www.torproject.org/download.html.en#Warning
To sum it up
If you want to surf anonymously, this is a very useful program as it also hides your IP-address. But remember that web apps like Flash can still expose your IP. A lot of people believes that installing Tor will automagically make them anonymous. That’s wrong however. You have to configure the application correctly you want to use with Tor. If you’re using Firefox, the Torbutton add-on makes this automatically.
A good idea might be to install a portable browser which you use only when you want to be anonymous. Configure this browser so it doesn’t accept cookies and install a flash blocker, block java and other “media” that could expose your IP-address. It’s recommended to only use services like webmail if the site uses SSL or another secure connection.
There is a portable version of Firefox called Firefoxportable.
Tor’s official website: http://www.torproject.org/