Sunday, February 23, 2014

Hosting my Own Private Wiki

I installed the MediaWiki package in my local server. It's an open source package for hosting a Wiki. So far I've setup a simple LAMP stack on my local server and then ran the MediaWiki setup script. It's pretty straight forward and downright simple. The LAMP stack has such a wide following that you can find documentation on installing it everywhere.

I used Ubuntu Server 12.04 LTS for this. There are a couple of different ways to setup LAMP through package systems. You can either use tasksel which automates the entire installation or install each package one by one.

I use the Wiki to document my studies into Unix and Linux administration. It's pretty cool that I can throw some of my writings and code onto a server and reference it afterwards. There are other ways to do this; using Google docs, or MS word, but the Wiki seems like the perfect medium.

It also occurred to me that I needed to backup the data on the Wiki. So I googled ways to do this. The simplest seems to be doing a mysqldump of my entries. Here's an example of that.

mysqldump -h localhost -u root --password --default-character-set=utf8 my_wiki > backup.sql




Thursday, May 2, 2013

Bookmarklet Storage Application

A couple days ago, I was growing frustrated with how tedious bookmarking had become. Whenever I wanted to bookmark a website I would save it, however I never got to use the link if I was on another computer. The method I used before was to save the link in Gmail and that is quite tedious. I decided I wanted to write a small application for myself that would save my links online.

Bookmarking on the web is nothing new. Sites like Instapaper and Delicious use a bookmarklet to run javascript that sends information to the servers in order to save information about the web site and the contents.

A bookmarklet runs javascript through the click of a bookmark on the browser. Using your favorite browser, you first create a bookmark and enter the name. On the second field where you would usually enter the URL, the code for your javascript behavior would be inserted instead. It would look something like this.

javascript: alert('hello');

Whenever you clicked on the bookmark you would then receive an alert saying hello. The real use in this is that you can grab information from the page you are currently on and do something with it.

In this case, I wanted to save the URL of the website and be able to go back to it later on any computer rather than just one machine.

Here where I had to figure out the work flow and also how application would be used.

1. Go to a web page.
2. Click on the bookmarklet.
3. Save the URL to a server.
4. Login to my database of links and view the URLs.

First going to a web page is not a problem. At this point javascript is enabled in most web browsers, so bookmarklets should work in most web browsers as well. Therefore steps one and two are pretty straight forward. Now I just needed the correct actions in javascript to send my URL to my server. After looking through some examples I figure this bit out. My javascript was something like this:

javascript:function mark(){
var prime=document,
ele=prime.createElement('script'), 
bod=prime.body,
locate=prime.location;
try{
if(!bod)throw(0); 
prime.title='-marked-'+prime.title;
}
}
mark();
void(0)

Basically I am creating a new element in the web page I am browsing. Then I set the attribute with the web page URL I grabbed along with my special code as an unique identifier. As a last step, I append the information to the page. It's the last step which enables the URL to be evaluated. Notice the '/?url=' where I set the URL of the current web page. That is the information I want to save.

Once the information has been sent to my web server, I can run a php script to save the URL to my database.


$url = $_GET['url'];
$userCode = $_GET['code'];

if ($userCode == "######") {

$host = "127.0.0.1";
$username=""; // Mysql username
$password=""; // Mysql password

$db_name="database name"; // Database name
$tbl_name="table name"; // Table name

mysql_connect($host, database username, password)or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="INSERT INTO table_links (link) VALUE ('".$url."')";
$result=mysql_query($sql);

}


In order to view the links, I created a second page that would display them using a mysql query.

And that was it. I now have a personal application that I can use to bookmark web pages. I can do that without having to register to a social media site like delicious to catalog those links.



Friday, April 19, 2013

Java terms

I am actively interviewing for technical positions and I would like to post about terms that are mentioned. These are terms that Java developers should know and I think should be able to describe and answer questions about. I was asked questions about them and I did not know about all of the terms. So this post is a warning to myself and others that these aspects of Java matter.

I will continuously update the list as I go through interviews and see what employers expect Java Developers to know.

Abstract
Interface
Object class functions
String comparison
Collection
 


Friday, February 15, 2013

Java 2-15-2013

Here's a status update on my studies. I've been using a practice exam check my aptitude after reading the study guide. I'm at chapter 3 Decision Constructs. In order to put my all into this, I have some ideas on how to do that.

  • Progress through at least one chapter a week
  • Read up on the topics discussed in the book
  • Code in Java on projects large and small
  • Read about issues in the Java programming community

Thursday, January 3, 2013

Java

I just got a Kindle for Christmas and that by far has become one of my favorite studying tools. It's super portable and lightweight. I have loaded a few texts on java to the Kindle and it works beautifully. I was also surprised at the battery life. It just goes for hours.
Now that I am focusing on Java, I also re-installed Eclipse on my laptop so I can work a project with it. I might get back into working on an Android program.

Thursday, December 20, 2012

Java and PHP



Well my friend is working pretty hard on learning Java and I want to join him. He has been using it for years and now wants to get ceritified with OCA SE7. That is something I would want as well. In fact, I want that a great deal. That is why I will merge my studies of PHP with Java for the time being and work towards getting certifications in both languages. Albeit, the issue of time is especially sensitive right now. I will need to give everything I have to working on this. I don't necessarily have to push myself to get the certifications right away. My plan is to work with my friend on the Java studies and also learn about PHP on the side.

Update

While learning about the PHP CLI, I began to wonder what exactly I could do with it. PHP has been used almost exclusively for web development. If there are uses for it besides that, I would be curious about it. Here are some articles from the php.net manual and some published materials from different sites on that.

http://www.ibm.com/developerworks/opensource/library/os-php-command/