Wednesday, May 9, 2012

I Moved!

Today it's official, out with the old in with the new. I'm done using blogger as a host to my blog and now moving to Wordpress. You might ask, why?
1. Wordpress gives me more control and customization
2. Wordpress is more professional
3. Wordpress doesn't mess up my Domain Name URL forwarding
4. Google can be scary with all their privacy policies.
5. Wordpress makes it easy for others to comment. No need for an account!

What does this mean to you.
You can access the site by going to baligena.com and all the content has been transfered there. This will be the last post on this server so if you ended here at this page go to baligena.com.

Monday, May 7, 2012

Installing Piwik

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 different 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.

Friday, May 4, 2012

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

Wednesday, May 2, 2012

You're a Business, The employed and self-employed

You probably heard it before "I enjoy being my own boss because I make my own rules and I have freedom". A very general description because you're free from WHAT? You may not have a person as a boss but that role is switched to your customers, they're your boss. You may have this false feeling of freedom but you’re bound to customer complaints, returns, paperwork and so on. It’s cool to walk around and say "I'm my own boss, I make my own rules" to your friends. But depending on the situation having your own business isn't the best idea. Being your own boss is still having a job but your responsibility is different, and many sacrifices are required to be successful.

I'm a business no matter what. If I'm an employee or employer whatever it is I'm still the owner of myself and the money I make. When I work I give my best and want to be compensated accordingly. If this can't be done, my business (myself) will switch different markets (job). When this market(job) is not cutting it then I should venture in new territories(self-employed).

There's always a flip side to the coin, a yin and a yang, risks and rewards and depending on the situation we find ourselves in we need to make the decisions for what is best. I'm all for starting your own business and it is my ultimate goal. I won't do it because I'm lazy of responsibility or work, but because my job just isn't cutting it anymore.

Monday, April 30, 2012

Quote: Seeds you Plant

“Don't judge each day by the harvest you reap but by the seeds that you plant.” -Robert Louis Stevenson

Friday, April 27, 2012

Server showing IP address in URL?

To link the domain name to your server the A (address) at the DNS site (eg. namecheap.com) needs to point to your public server IP address. Recently I was having an issue with my site because when I typed baligena.com it went to the site however when I click on a link it would be replace by my IP address in the URL. It's funny when you call for tech support its a waste of time because this shit is too advanced and they won't be able to help you. What I figured out it wasn't the domain name nor the server that was causing this error but Wordpress. Wordpress has an option to specify your site URL.

Wednesday, April 25, 2012

Point Domain Name to your Server

My domain names are hosted by namecheap.com after I decided to make a switch out of godaddy.com. However, I never got around to point my domain name to my server instead I had a simple webpage redirect. Below is a conversation I had with their support team where they explain to me what types of re-directions are and how configure it.

You are now chatting with Natalie Z. - Domains Support
21:47Natalie Z.: Hello, you've contacted Live Support! How can I help you today?
21:48kaka: I have a server where my website is located. I'm trying to use my domain name
21:50kaka: I'm basically trying to forward the domain name not a redirect. How do I do that
21:51Natalie Z.: What exactly you wish to configure on our side? Change nameservers? Create some host record? Create URL redirect?
21:52kaka: What is the difference between changing nameservers and URL redirect
21:55Natalie Z.: If you change the nameservers, you will delegate domain's zone file to the side of your hosting provider and you will need to manage host records there. If you set up URL redirect, you just make the domain redirect to other one, the nameservers are not changed, host records are managed on our side. Changing nameservers will give you some options on the side of your hosting provider to manage your domain there
21:56kaka: I have my server IP address and I want my domain name to direct me to it. But I dont want masking redirect but an actual change. Do understand what I mean?
21:57Natalie Z.: If you need to point your domain to IP address, you need to do the following
21:58Natalie Z.: Go to My Account -> Manage Domains, click on the domain and after the page refreshes choose All Host Records at the left side menu.
21:58Natalie Z.: You need to enter your IP address (xxx.xxx.xxx.x) for both the www and the @ fields and choose A (Address) as the Record Type from the drop down menu. Save changes
21:59kaka: what is the difference between A(address) and URL Redirect
22:01Natalie Z.: A (address) record should be created when you want to associate your domain or subdomain with IP address. URL redirect is used when you just want your visitors type the name of your domain in the address bar and being redirected to any specific web page
22:02kaka: what do i put in for TTL?
22:03Natalie Z.: You can put 1800 as a default value
22:06kaka: If I wanted direct to a specific location in my server like xxx.xxx.xxx.x/myfolder is this posible?
22:07Natalie Z.: Unfortunately, with A record it is not possible
22:07Natalie Z.: This should be configured on your server directly
22:09kaka: How long will it take for the changes to take effect?
22:10Natalie Z.: The changes will take effect within 30 minutes
22:10kaka: ok thank you

Monday, April 23, 2012

Adventure into Electronics

I'm a programmer and don't know anything about electricity, circuits and things in that family. Recently I decide to start programing microcontrollers in order to build these cool physical gadgets I see in the interwebs so I bought me an Arduino to get started but stood looking at it like a deer starring at headlights because I didn't know where to start. Next I bought Make: Electronics book to get me started. One major difference between building software and circuits is that one cost money. In order to build your circuits you need to buy parts and I went out today to Radio Shack and dropped $45.00 on these simple items. Slowing but surly I'm desensitizing to this technology. I'm not sure where this may lead but it looks promising.

Friday, April 20, 2012

I'm not IT bitch

The one thing that makes me cringe is when someones asks me if I'm IT or should do IT. Many miss use this term because they're ignorant.

I agree with Linus Torvalds and this is what he said:

"Oh, the absolute *last* thing I want to do is be seen as a support person. No way.

But I’m simply not really organized enough to be a good MIS person. And frankly, I lack the interest. I find the low-level details of how computers work really interesting, but if I had to care about user problems and people forgetting their passwords or messing up their backups, I don’t know what I’d do. I’d probably turn to drugs and alcohol to dull the pain".
source

I don't want to help you fix your mistake, your lack of knowledge, fix your screen resolution. I'm a programmer, I build things, I'm not IT bitch!

Wednesday, April 18, 2012

Programmer Hiring

When I started programming I kept hearing recruiters are clueless and don't know what they're doing. I recently ran into one who made me take a test at geekinterview.com

First I'm not a geek just because I'm a programmer. By definition I'm NOT a person regarded as foolish, inept, or clumsy.

Second, the questions were wrong like saying PHP is a programming language when in its a scripting language, some were dumb like who is father of PHP, who cares! How does knowing this make your software any better, some question were deprecated and finally bad practices and obfuscated. Overall silly!

Now I wonder what kind of developers they have employed. Recruits don't understand that programming isn't a multiple choice test and not necessary what you know but what you can discover. Without the internet I'm a worst programmer because I use it like an extension of my memory. I don't try to memorize every single function in a language because I'm not going to use them all and I can build my own if I have to.

Friday, April 13, 2012

Too many Options

Options are great but at times it can be a burden. As a programmer we have all kinds of goodies such as open source tools and languages. We have the option to choose whatever but it can lead to indecision, over thinking and incompleteness.

Did you ever start a project or idea but not finish it because another option appeared? When younger we normally had 2 or 3 games for our SEGA and we played those games so many times we could easily sing the songs. Now I have many games its a sacrifice to finish one.

Less options makes life simpler. Imagine if you had 5 toothbrush to choose from. How frustrating every morning would be and you'll probably end up using only one anyways.

Don't confuse less options with laziness to achieve them. I can but don't because I choose not to. Because the harder you work the more options you get.

Simplicity is what I strive for, not how cool looking or complex my code is. If it gets the job done why will I put an unprofitable twist to it?

Wednesday, April 11, 2012

SSH in Windows

One might ask "why do you need ssh?" And if you don't know what ssh is, learn it? It's very useful, you'll thank me someday.

The problem I was having is that ssh is shipped with Unix operating systems such as Linux and iOS but not on Windows. What if I need to securely access my files on my Windows computer, what will I do? No worries you can have ssh on on Windows but it takes extra work. You'll need to install cygwin a Unix-like environment and command-line interface for Windows. Click Me for detailed instructions on how to set it up.

Friday, April 6, 2012

Hello world in Node.js

First you need to install node.js. I'm running ubuntu 11.10 and I also needed to
$ apt-get install openssl libssl-dev

Create a file named test.js, and copy and paste the code below

//how to run the server output hello world
var http = require('http');

var server = http.createServer(function(request, response){
response.writeHead(200, {
'Content-type' : 'text/plain'
});
response.end('hello world');
});
// where the host in located
server.listen(8000); //see the code below
console.log('listening on http://127.0.0.1:8000'); //echo in the terminal whatever you want
To start the server go to the terminal and the run the script you created by typing
$ node test.js
Now go to the browser and enter http://127.0.0.1:8000 and your done.

Resource: http://net.tutsplus.com/tutorials/javascript-ajax/this-time-youll-learn-node-js/

Wednesday, April 4, 2012

Downloading files using PHP

Put the file you wish to download in your website directory. Example:
/file.rar

Now when you want to download it just go http://mysite.com/file.rar

It's that simple, don't over complicated it and you don't need PHP. Yesterday I tried to figure out how to download files but ran across all kinds of complicated methods. Using HTTP heaters, download helper; force_download in codeigniter, and PEAR. Maybe the reason I had such a hard time finding the solution was because its too obvious. Shot! I personally missed it.

Tuesday, April 3, 2012

Finish Strong

When in middle school I ran track and one of the things my coach taught was to pace yourself. But as rebel I had to learn the hard way. I tried to run a full sprint in the beginning of a 400 meter race and lost all my speed 3/4 of the way. It felt wonderful being in first most of the race but all of that went away when I almost finished last. It was a good start, but what's the point if the finish is horrible.

This analogy can relate to any goal. You may start off slow but if your pace is good you will finish on top. Slow but steady wins the race. Show me someone who is consistent and I'll show you a successful person. Lesson learned!

Friday, March 30, 2012

Lazy programmer? Not really!

Influenced by an article, I wrote about how programmers are lazy people, but I take it back because it's completely far from the truth. It's true that no one likes repetitive tasks but they also don't have the desire or willingness to learn how to get rid of it, but programmers do.

We are consistently learning, building, and putting in the effort to be more efficient. Our desire to free up time puts out a lazy illusion which sometimes fools even ourselves(I'm a victim).

First and foremost programming isn't easy and it takes a lot of effort. We want to automate not because we are lazy but efficient. We are always trying to see how much we can get done in the least amount of time. Would you call yourself lazy because you drive to work instead of walking. No! because walking would take 5 hours instead of 30 minutes to arrive. Never did I build a program so I can just do nothing but free my time to do something else. So stop calling yourself lazy, it doesn't make look cool.

Wednesday, March 28, 2012

Post PC era, Really?

Recently there's been a lot of people talking about how the post PC era is upon us because of all these smart phones and tablets. Let me tell you secret, it's not true but I'll let you be the judge.

Would you trade up your keyboard for an on screen one? Would you trade power and speed for convenience? Would you trade Skyrim for Angry Birds?

If you said yes to those questions you probably use your computer like a Television, passively. Surfing the net, snooping other people lives on facebook and that's it. And yes! Post PC era has arrived for you because you never belong with a PC anyways. For someone to think that a tablet will make a PC obsolete is ridiculous. This is all propaganda for you and I to be another victims to advertising.

How can a tablet ever beat a PC in programming, special effects and gaming. Tablets were supposed to come before PC but we decided to skip it. When I first got an iPod Touch I used it a lot for downloading games and apps but now the only apps I use is Twitter, email, notes and calculator because everything else is really not that important.

Monday, March 26, 2012

The Answer

“Nothing in this world can take the place of persistence. Talent will not; nothing is more common than unsuccessful people with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent.” -President Calvin Coolidge

Friday, March 23, 2012

htaccess python script, Clean URL

I enjoy the clean URL when it looks like http://baligena.com/home/page

However every time I create a new app I have to re-edit/create a htaccess file. This is too much work and remembering. Below is a python script for windows and linux that once ran inside the root folder of your site it will create an htaccess file to make that clean URL you always wanted. You can also fork it at GitHub

Warning! You may need to configure apache and php for the htaccess file to work. Click me for instructions.

createhtaccess.py



# this script customizes and creates the .htaccess to correspond to the current directory

import os

def create_htaccess():
f = open('./.htaccess','w')
# get directory path
directory = os.getcwd()

# if linux
if os.name == 'posix':
dirname = directory[directory.rfind('/')+1:]
# if windows
elif os.name == 'nt':
dirname = directory[directory.rfind("\\")+1:]
else:
exit('error occurred: couldnt determine the system this computer is on')



f.write('''
# http://codeigniter.com/wiki/mod_rewrite
# make sure you change the root url on line 27 RewriteRule ^(.*)$ directory/index.php?/$1 [L]


RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ '''+ dirname + '''/index.php?/$1 [L]



# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php

''')
f.close()

if __name__ == '__main__':
create_htaccess()



Wednesday, March 21, 2012

Hit the road Dogma

Steve Jobs said it the best "Don't go out living other people dogma". In business, programming, sports and life people want to force their opinion on you wishing they had what you have and then telling what you should do. Oh if only I had your age, lack of money, computer, size of your head, number of toes.

When someone finds out that I'm a programmer they say "oh that makes a lot of money, you should work for blah blah blah". Why? What if I want to keep programming interesting and fun, not make into a dreading job.

People will hate on someone who finds satisfaction in things where the majority won't. If a millionaire lives a simple life or if a young professional athlete is not living a party life and has a strong religion(Tim Tebow) their must be something wrong with them.

Let my neighbor do his thang and I'll do my thang. I have my style, my vision, my perfection, my imperfections and if I have to change I will but not because of dogma.