C++ GUI

I’ve been reading a C++ book for a couple of months now and waiting to arrive at the part where I get to build programs where I can click, drag and drop. Then I realized that the book doesn’t cover that, so I went searching for it. I found alot information on a framework called Qt by Nokia and it looks promissing. I haven’t tried it yet but it will be on my agenda to do so. If popular softwares like Autodesk Maya and VLC media players uses it, it must be good. If you used it and liked or hated it leave a comment below.

Install PySide

How to install PyQt4

Installing Truecrypt in the command line

Download the console only Truecrypt at
http://www.truecrypt.org/downloads

extract it and the shell script (.sh) will appear then run it
$ sh truecrypt-7.1a-setup-console-x86

Truecrypt Command Line Usage

To run truecrypt
$ truecrypt ./volume

—-
Installing truecrypt in linux apt-get

Tags:
console, ubuntu server, terminal

Block IP Address Access to your site

It seems that spammers are usually the same people. If your site isn’t that big you can block these people by their IP address with little work. In WordPress every time someone comments on your blog their IP is shown. Below is how to block with Apache .htaccess file.

order allow,deny
deny from 255.0.0.0
deny from 123.45.6.
allow from all

Blocking of all visitors except yourself:

order allow,deny
allow from 255.0.0.0
deny from all

Detailed information click here

Spam on Blog

Geez, I recently switched from Blogger to WordPress and boy do people like to spam. The great benefit about switching to WordPress is the facility of user feedback but on the flip side you get spam like crazy. It makes me wonder, are my views actual people or bots.

I’m not smart, I work hard

“Your Smart!” They said to me but I replied, “not really, I just work hard”. It’s funny when someone comes to me and calls me smart when couple years ago, supposively I wasn’t so smart. I’m not smarter than the next average Joe but a harder worker, let me tell you.

If they saw me everyday trying to program, reading a book, learning a little a day everyday they would see its not about physical ability or genetic lottery but determination with a mixture of perseverance.

It doesnt matter how much you explain to someone they can never understand the time, the tears, the sweat nor the blood it took to get me to the “smart” part of my life. Many are fooled because they believe they can’t achieve the same results but the only thing keeping them from reaching it is the ability to put in the work. It’s not possible to change overnight but you can change your direction.

Code Snippet: Simple Javascript Progress bar

This snippet uses jQuery

<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <style>
        #border{
            border: 1px solid black;
            width:500px;
            height:16px;
        }
        #progress_bar {
            height:16px;
            width:0px;
            background: red;
        }
    </style>
</head>

<div id="border">
    <div id="progress_bar"></div>
</div>


<script>//progress/status bar    
var len = 3;
var bar_size = $('#border').width();
//alert(document.getElementById('border').width);
var increment = bar_size/len;
var fill = 0;
for(var i =0; i<len; i++){
	fill += increment;
        $('#progress_bar').css('width',fill+'px');
}
</script>

Piwik Installation

Piwik is an open source website traffic analysis. I decided to give it a try over google analytics, one of the reasons is because the data can be stored on my server if I choose to and its fast.

Installation was simple, One may be confused by the different versions piwik has such as a plugin for wordpress and the actual source. The plugin for wordpress is only an integration that cannot be used by itself but with the actual source installation. Piwik can be installed on any server and it doesn’t need to be inside wordpress directory. Below is a non-english video which shows how to install it. What he says is not important.

C++ MVC example

I’m calling this a MVC example for simplicity. It’s actually separating 3 c++ files into 3 different responsibility for better organization and reuse-ability.

coordin.h
This is the header file which contain templates and functions prototype. This file will be included on the other 2 files.

#ifndef COORDIN_H_
#define COORDIN_H_

//structur templates
struct polar{
char from[50];    //distance from origin
char description[50];       //direction from origin
};

//prototype
int balls(polar test);

#endif

file2.cpp
This file contain functions called in file1.cpp

# include <iostream>
# include <cmath>
# include "coordin.h" //structure templates, function prototype, what links the scripts

//convert rectagular to polar coordinates
using namespace std;
int balls(polar test){
cout << test.description << endl << test.from << endl ;
}

file1.cpp
This file is where you put the meat of your program. This is where you bring all the previous files together.

#include <iostream>
#include "coordin.h" // structure templates, function prototypes.  what links the scripts
using namespace std;

int main(){
polar test = {"mvc like","must compile both file1 and file2"};

balls(test);

return 0;
}

Now in order for this to work you must compile both file1.ccp and file2.cpp at the same time. Example:
$ g++ file1.cpp file2.cpp