Monday, December 21, 2015

Sunday, December 06, 2015

Calling non-static method from static method in Java

You might find it useful to call non-static methods from a main method in Java. You can easily do this by creating a class instance and calling the non-static method using that instance in your static method. Sounds complicated? Checkout the example:

Friday, October 30, 2015

Saturday, October 17, 2015

Ralink RT5370 USB WiFi adapter on El Capitan 10.11.x

Note: These instructions are valid for the following drivers: RT2870/ RT2770/ RT3X7X/ RT537X/ RT5572

In a previous post I showed you how to install the Ralink RT5370 and equivalent USB WiFi adapter for OSX Yosemite 10.10.x. In this brief post we will use the information learned in that previous post and adapt it to install the same driver on the new OSX version released a few weeks ago, El Capitan 10.11.x.

Note that throughout the article I will make reference to the following tools and drivers that you can download from here:
1. Bear Extender (GUI for managing the WLAN)
2. RT2870USBWirelessDriver.ext (The Ralink Driver)
3. SIPUtility (an application to manage El Capitan SIP)

But before we start you should understand that Apple made a number of security changes to El Capitan, one of them called SIP (System Integrity Protection). Follow the link for more details about SIP, but the most relevant to us is to understand that in a nutshell the driver will not work (load into the kernel) out of the box, and we need to disable SIP completely for it to work.

As such you need to first run the SIP Utility (credits go to the hacker cvad) to disable SIP completely:


Reboot your machine, and then copy the RT2870USBWirelessDriver.ext driver to /System/Library/Extensions:


Final step is to install the Bear Extender WiFi management GUI. Once you reboot the machine once more, you are able to use the Ralink driver on El Capitan!




EDIT (8/11/2015): I have noticed some people find it difficult to use SIPUtility or install the package manually from the terminal. If you're not comfortable with the terminal, there is an easier alternative by using Pacifist:
1. Download Pacifist from https://www.charlessoft.com/cgi-bin/pacifist_download.cgi?type=dmg
2. Open the installer.pkg file from the driver you downloaded in pacifist, and select to install to default location, and use administrator privilege
3. Reboot
4. Install Bear Extender WiFi management GUI. Once you reboot the machine once more, you are able to use the Ralink driver on El Capitan!

EDIT (10/11/2015): If you are having issues to disable SIP with SIPUtility, you may try the KCPM Utility Pro.


Friday, October 16, 2015

Docker Fix "cannot enable tty mode on non tty input"

Running docker on windows can be a bit challenging for newcomers. This is mainly because Docker was actually meant to run on Linux environments (LXC containers). One of the most common challenges among Windows users is to attach a TTY session to a docker container to run for example a bash shell.

Inherently, the Docker command tool for Windows, which is based on Cygwin/Mingw does not have TTY input, and the following error will pop up:



The workaround is to use winpty (which comes with Mingw):
alias docker="winpty docker"

Friday, September 25, 2015

Chocolatey - Windows style apt-get package manager

Just discovered a nifty package manager for Windows - Chocolatey. Do not get fooled by the silly name - choco has 3k packages to choose from and give the Windows power user plenty of opportunities to automate stuff.


Monday, September 21, 2015

Git for Windows

Due to new workplace I had to adapt myself into using Windows (who would have thought after more than 15 years as a Linux power user!!). It took me long to discover a great tool to use for Git - called Git for Windows.

Not only it comes with a handy GUI to visualise commit history, branches and version control, but it comes with a 'Git Bash', which is a console loaded with Linux tools!

Saturday, June 13, 2015

Histograms in Mac Excel

In this quick post I will demonstrate how to create a histogram in Mac Excel including the Bin Labels as x-axis.

STEP 1: Start with your data formatted as bin and individual frequency (that is derived from the cumulative frequency).



STEP 2: Highlight the entire table, click on Charts, and select Column. You will end up with an incorrect histogram which we'll fix in the next step.



STEP 3: Fix the histogram y-axis values by keeping the correct series (IQ bin).



STEP 4: Fix the histogram x-axis values by copying the IQ bin raw data and then Paste Special inside the Chart (by selecting it before pasting). The data needs to be pasted as a new series with Values Y as Columns, and X Labels as Categories. Make sure you check the box to replace existing categories otherwise it will not work.




STEP 5: You will now end up with the correct histogram.















STEP 6: If you want to widen the bars, right click on one bar, and select "Format Data Series..". In the "Options" tab adjust the "Gap width" to 15%.




STEP 7: Final result.


Friday, June 12, 2015

WiFi Cascaded Home network

I had some free time to design and build a cascaded WiFi network for my home. I have recently bought a TPLink router (TL-WR841HP) to replace an older MSI WiFi router because I needed to cover all the house with WiFi. 

The TL-WR841HP is great, and to be honest I did not actually need to cascade the network because it's Signal Power is rated x4 the conventional routers - so that covered almost the entire house! Having said that, I wanted to dedicate a router just for first floor where I have my Android box streaming HD movies, so I wanted to squeeze all the juice through a singular router (MSI). 

The setup is shown below and quite self explanatory. If anyone wants more details, just drop me a comment.





Friday, June 05, 2015

RT5370 USB WiFi adapter on Yosemite 10.10.x

Got myself one of these cheap RT5370 chipset based USB WiFi Adapters (C1288) for my old Macbook Pro whose airport card died. Naively I thought that it was just a matter of plug 'n play... But Yosemite made it difficult for me and I have literally spent 7 hours to find a solution.



So I am going to explain what needs to be done in a few steps and of course in a way that even non-hackers can understand. Note that this solution will work on a number of Ralink and Realtek chipsets. 

(Hint: Do you want to do a quick business? Click here to order x10 of these WiFi dongles and follow the instructions to install on to your clients. Thank me later!).

STEP 1:
Download and install this package. This will install the KExt for Yosemite. Do not Reboot yet.

STEP 2:
Edit Info.plist (/System/Library/Extensions/RT2870USBWirelessDriver.kext/Contents) and add the following code:

Note for the hackers: I added a new key for the Product ID and Vendor ID of this particular dongle (Get this from the system profiler). Make sure you translate Hex value to Decimal. For example in my case Product Id is 0x7601 (decimal: 30209) and Vendor Id is 5263 (decimal: 5263).

STEP 3:
Fix Permissions and Refresh Kext by running the following code in terminal:

STEP 4:
Download and copy the DWA-140 utility to the System Preferences pane:


STEP 5:
Reboot

If you go to the System Preferences -> DWA-140 (at the bottom), you should be able to see the nearby WiFi networks (or far ones if you connected an external antenna!).


Since I have a hidden SSID WiFi router (security through obscurity!) I had to manually enter its details by clicking on the "Create Profile Drawer" and add a new profile for my connection.


The reliability and performance is excellent to say the least:



EDIT: Some people experience difficulties with the DWA-140 utility. As a recommendation you can try the MediaTek tool. Download and copy to your applications folder.

Monday, February 23, 2015

My Malta Marathon 2015 experience

My first marathon, therefore my personal best. The ‪Malta Marathon‬ was a test of mental fortitude. My legs are shattered but my spirits are high!
















Tuesday, February 03, 2015

Monday, February 02, 2015

My first (almost) 18km run

An achievement followed by some sore muscles and in anticipation for the half!


Thursday, January 22, 2015

The Art of Decision Making - Sunk Costs

One of the life changing concepts I have recently learned during my MBA studies is to when effectively walk away from a business. Let's face it, we have more or less been all living in a society which dictated the myth that as long as we have previously invested substantial energy, time and money into something, we should continue doing it, even if the future benefit might get negative or we just hope to bring in some profit.

After studying about the concepts of relevant costs I do not agree with this traditional reasoning - past costs, known as sunk costs, should be never accounted in future decision making. You should just look at the present...the t = 0, when considering costs... Look at it this way - wondering about the future? Then consider only the FUTURE costs and the FUTURE benefits. The future benefit should always be more than the future cost if you decide to give green signal to a project.

For most people, including business men, they find it difficult to detach themselves from something which costed them lots of money and energy to get that far and they aren't seeing the profit yet. This is wrong.

Now quick question for my blog readers to ponder about: How many times did your manager, CEO or CFO, base his financial decisions on irrelevant sunk costs? And what can you tell about the outcome of such decision?