Tuesday, October 4, 2016

My ideas for thesis papers for under grads

I have lots of ideas regarding students' projects, some I really thought about while others just came pass my mind. Here are some of them:

1. Water bill counter-checker
This involves a device and a software. The idea is to check the actual consumption of a household versus the billed consumption. Maybe a device could be installed in all of the water outlets in the house, including the toilet flush, to check how much water are discharged and if it reflects properly on the billing. The goal is not to bill the consumer since water districts add other fees in the bill. The goal is to just check if the amount of water recorded in the billing is close to the actual amount discharged. This can help check if there are tapped connections or leaks that the household is unaware of.

2. Street lights auto switch
I've seen some street lights that are still on even thought it's already noon time. What a waste of electricity! So I thought, why not have an automatic switch that turns them on at 5:30pm and turns them off at 5:30am? Of course a manual override should still be possible.

To be continued...

Monday, October 3, 2016

How to access MySQL database of your website using SQL Yog

To be able to do this you should have the following:
- permission to set-up and configure your hosting database
- username and password to access the database

1. Login to your web hosting control panel and select the option for Remote MySQL.
*You need this because we want to access the database remotely, using SQL Yog.
If you're using SiteGround's hosting, the icon for Remote MySQL looks like this:



2. Add an access host.
You can get your public IP Address and put it as access host. This means that your IP address will be recognized by the database so that you can access it. If you're not sure of your IP address, you can put the percentage (%) which means "wild card". This will allow ANY IP ADDRESS to access your database. This will work but is DANGEROUS so better set your IP instead.


3. Set-up SQL Yog to access your website's server.
Just input the credentials and you're good to go. Be careful with your live data! Make sure to BACK-UP first before touching anything. And oh, secure your backup in a proper location too!

The values are as follows:
Saved Connections - this is the name of your connection just for you to easily recognize it. Any name will do.
MySQL Host Address - this is the name of your website (ex. www.example.com) where your database is located. Note that if the database is in a different server you may put a different name here. You can also put the IP Address instead.
Username - your database username. The one that you used to access your database.
Password - your database password.

Hope this helps.

Monday, September 26, 2016

How to put icon on the tab of your website

Let's keep it short!

This icon is called FAVICON. Here are the steps to put an icon or image of your website that will appear on the tab of the browser, just before the website title:

1. Create an image sized 16x16 and save it as png.
2. Put this code snippet on the <head> part of your website.
<link rel="icon" type="image/png" href="favicon.png">
Note: Make sure that the image name and location in your href is correct.

Example of implementation is:
<head>
<link rel="icon" type="image/png" href="favicon-juanreview.png">
</head>

I implemented this in my website JuanReview (www.juanreview.com)!

Monday, May 30, 2016

Review on PLDT Home Ultera

Q: Why did we get PLDT Home Ultera?
A: We didn't. We had a SMART Bro connection at home for 999 per month. One day, a technician from SMART went to our house and said that there's a mandatory "upgrade" which means faster internet for the same price. Of course we availed! Who didn't like upgrades right?

P.S. If you look at it, Ultera is offered at 699 at the market now and we're still freakingly paying it for 999 a month because we're still with our previous SMART Bro Plan 999. Unfair.

Q: So how was it?
A: Let me count the ways:

1. Our bandwidth increased BUT we have this limit of something-Gig worth of download per month. If we reached our limit, the bandwidth will decrease. Talk about Torrent downloads, we cannot maximize the connection unlike when we we're still on SMART Bro.

2. We cannot change our own router's user name and password. Which sucks! We have this theory that our router is connected to a "mother" router where all Ultera users in our area are connected that's why we cannot change the router's username and password.

3. We're getting a LOT of captcha every time we browse. Which sucks, again!
Whenever we click a link from facebook or even going directly to a site, a page for captcha needs to be answered first. Every. Effin. Time. When you browse, you need to fill up a captcha. When you want to read an important article, you need to fill up the captcha. What the?!

Most of the time, the captcha is like this:

Q: Will you recommend it?
A: No. Our internet got slower. Sometimes the internet connection gets lost. A million captcha needs to be filled up before you can browse. Just No.

Sunday, March 6, 2016

How to "Select All" or Highlight textfield or password field in Java

There are cases when you want to select all or highlight the characters inside a textfield or password field in your Java desktop app. Here's a sample code to do that:

int i = textfield.getText().length();
textfield.setSelectionStart(0);
textfield.setSelectionEnd(i);


Put this in the action or wherever you want it. Replace textfield variable to the name of your textfield. I'm not sure but this might work for JTextArea and JTextPane too.

How to change any date format to DATE datatype in MySQL (Insert or Update)

Use this function: STR_TO_DATE('date', 'format')

This accepts two parameters: date and format where date is the input raw date you want to change and format is the corresponding format relative to date that you want to change.

For example: INSERT INTO table(date_field) VALUES(STR_TO_DATE('December 8, 2010','%M %d,%Y'));

Note: table is the name of the table in database and date_field is the name of field in DATE datatype.

The statement above shows 2 parameters date as 'December 8, 2010' and format '%M %d, %Y'. The format is the exact format of the date, so that the mysql knows from what format will it convert the date to DATE datatype format which is '%y-%m-%d'.

Other valid examples are: INSERT INTO table(date_field) VALUES(STR_TO_DATE('12-31-2004', '%m-%d-%Y')); INSERT INTO table(date_field) VALUES(STR_TO_DATE('12/31/2004', '%m/%d/%Y')); UPDATE table SET date_field = STR_TO_DATE('Dec 31, 2004', '%b %d, %Y');

How to maximize frame or window in Java (JFrame)

There are multiple ways but I recommend these lines of code:

GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); Frame fr= new Frame(); fr.setMaximizedBounds(e.getMaximumWindowBounds()); fr.setExtendedState(main.getExtendedState() | JFrame.MAXIMIZED_BOTH); fr.setVisible(true); 

The code above will maximize your frame/window without hiding the taskbar (at the bottom part) of your screen except if you used undecorated frame. Any maximizing will hide your taskbar. This is according to my own experience but if you found ways to against it, please post it as a comment. Thanks :)

Friday, February 5, 2016

How to run MySQL queries from Windows Command Prompt (cmd)

Warning: READ CAREFULLY

I am writing this post because I cannot find something like this over the internet. For some reasons that you do not want to use MySQL GUI and just wanted to run mysql cmd but you cannot seem to run its own command line, your other option is to run it through window's cmd. I just want to point out that there are two command prompts that you can use to manipulate your MySQL database. One is MySQL server's command line and the other is through Window's command prompt. BOTH OF THESE METHODS REQUIRE YOU TO HAVE A MySQL SERVER INSTALLED IN YOUR UNIT.

You can get MySQL Server through (but not limited to) the following:
1. Downloading and installing MySQL Server.
2. Using application server platforms like Wamp, Xampp, lamp or mamp, whichever works for your unit. These application servers installs MySQL Server too.

The point is, you have to have a MySQL Server installed in your unit!

To be able to run MySQL in Windows command line, do the following:

1. Make sure that your MySQL is turned on. 

  • In application servers (wamp, xampp, etc.), you may start the service of MySQL.
  • To force start of server, locate the MySQL files and run mysqld.exe.  

2. Locate your MySQL server executable file.
  • Look for your MySQL server exe file. Usually, it is installed in C:\Program Files\MySQL\MySQL Server x.x\bin. 
  • The MySQL Server x.x defines the version of MySQL in your unit. Example: C:\Program Files\MySQL\MySQL Server 5.6\bin
  • You may use Window's search to find this.
3. Open windows cmd.
  • You can either open this from your Start button or use Windows+r to run cmd to open the command prompt.
4. Go to the root directory in Windows cmd. 
Type cd.. then hit Enter button until you encounter the root directory of your unit (C:\)

5. Type the address of your MySQL Server

  • Your address should not contain the C:\ directory instead, replace it with cd. Example: cd Program Files\MySQL\MySQL Server 5.6\bin
  • The directory should change based on the address you typed. 



5. Login to MySQL Server

  • Type the login statement: mysql -u username -p
  • For example, mysql -u root -p
  • Enter your password

6. DONE! You've now successfully logged in into MySQL using Windows cmd.
You can now make your database, tables, queries, etc.