Sunday, January 12, 2014

Lightweight Eclipse Installation (Java)

Hi,

For those of you working with Eclipse, or those who must work with Eclipse, you might want to get a lightweight installation. Not only will it let you install plugins yourself (and learn in the process) but it will be fast, barebone and bloat free.

First, get the Eclipse Platform Runtime Binary.  Go to http://download.eclipse.org/eclipse/downloads/ , then scroll down to the latest release. Then find the section and download the correct Eclipse for your architecture.



After you download, extract and run Eclipse all you need to do to get Java is go to Help -> Install New Software. Then filter with "Java" and download the Eclipse Java Development Tools.



When it's complete you'll have a fast, bloat free and ready Eclipse installation. Check by going to File -> New Project and seeing if Java Project is there.










Do the usual setup of classpath, Java runtime etc., and you're good to go.

If you spend hours and hours in front of Eclipse, you might need a black background so it doesn't kill your eyes. Get the Moonlight UI theme here: then Eclipse color themes here  . Your Eclipse should look like Sublime now.

screenshot

Saturday, January 11, 2014

Installing Linux Mint on a Asus UX32VD Laptop (or any laptop) PART 2 - Graphics Ubuntu Bumblebee

Hi,

This will be a short post today as my week has been busy. However, it's an important one.

To get the integrated graphics working with UX32VD or any other laptop with NVIDIA Optimus for that matter, you must use Bumblebee. It's officially supported by Ubuntu Saucy (13.10) or later, which includes Linux Mint Petra or higher.

See here for the details. (Note I am only giving instructiosn for 13.10, see Ubuntu documentation for earlier versions).

Basically you will need to do the following:

1. Add bumblebee PPA


sudo add-apt-repository ppa:bumblebee/stable


2. Enable universe and multiverse


sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
sudo vim /etc/apt/sources.list  
 
Uncomment/add the following lines for universe and multiverse



deb http://us.archive.ubuntu.com/ubuntu/ saucy universe
deb-src http://us.archive.ubuntu.com/ubuntu/ saucy universe
deb http://us.archive.ubuntu.com/ubuntu/ saucy-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ saucy-updates universe
deb http://us.archive.ubuntu.com/ubuntu/ saucy multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ saucy multiverse
deb http://us.archive.ubuntu.com/ubuntu/ saucy-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ saucy-updates multiverse 

3. Install Bumblebee including 32-bit support


sudo apt-get install bumblebee bumblebee-nvidia primus primus-libs-ia32 linux-headers-generic


4.  Install NVIDIA 319 Updates


sudo apt-get install nvidia-319-updates nvidia-settings-319-updates 


5. Install nvidia-settings

sudo apt-get install nvidia-settings

5. Modify /etc/bumblebee/bumblebee.conf file. Find the section [bumblebeed] and change Driver=nvidia .

Also find the section under [driver-nvidia] and also add Driver=nvidia (it is in two places).

Next under the [driver-nvidia] section modify the following:
 
Driver=nvidia
KernelDriver=nvidia-319-updates
LibraryPath=/usr/lib/nvidia-319-updates:/usr/lib32/nvidia-319-updates
XorgModulePath=/usr/lib/nvidia-319-updates/xorg,/usr/lib/xorg/modules 
 
Save the file  and restart the Bumblebee daemon with
sudo restart bumblebeed 
6. Finally, use the discrete graphics by testing optirun and comparing framerates


sudo apt-get install mesa-utils
optirun glxgears
glxgears


See the Ubuntu documentation on Bumblebee for more details including how to uninstall it and go back to the nouveau driver if you're unsatisfied.

Now, whenever you run a graphics intensive application (games and so on) start it with optirun.

Tuesday, January 7, 2014

Connecting to Oracle from ASP.NET, ASP.NET MVC and .NET Applications (Configuring web.config)













UPDATE: THE STEPS BELOW WERE WRITTEN TO IGNORE ORACLE INSTANT CLIENT. I HAVE SUCCESSFULLY DEPLOYED WITH ORACLE INSTANT CLIENT AND NOW RECOMMEND IT TO ANYONE WHO NEEDS TO SHIP ORACLE DRIVERS AND INSTALL INSTRUCTIONS WITH THEIR PRODUCT. ORACLE INSTANT CLIENT IS ONLY TENS OF MB WHILE THE OTHER OPTIONS ARE HUNDREDS OF MB. THE ONLY REASON NOT TO USE ORACLE INSTANT CLIENT IS IF YOU MUST SUPPORT ORACLE VERSIONS EARLIER THAN ORACLE 10g.

Hi,

I would like to address a misconception I found while browsing forums. Namely, how to connect to an Oracle database from ASP.NET or ASP.NET MVC web applications and whether it was a simple as "changing connection string".

Normally Microsoft developers are heavily into Microsoft to the point of knowing nothing of anything else (nothing wrong with that, just specialization). So when they encounter Oracle they expect it to be as hassle free as SQL Server. That isn't the case.

There are several approaches to connect to Oracle from a .NET application :

1. Write your application to use Oracle. If you are writing a new application this is the best approach. Use ODP.NET Managed Driver and develop your .NET application to use Oracle specific code. The advantage of this is no installation of Oracle Client required when deploying to third parties. The disadvantage is you'll need to maintain two separate code bases for SQL Server and Oracle. This is not as big a problem as it seems if you use a proper design pattern and factory classes.

2. Use Oracle Client. There are many versions of Oracle Client, ranging from Oracle Instant Client to version specific clients.
  • There is an Oracle product called "Oracle Instant Client". However, Oracle Instant Client lacks tnsnames.ora or listener.ora or any other such manual configuration. Oracle Instant Client is only available on Oracle 10g or higher (and a specific version of that as well.) Therefore, I do not recommend Oracle Instant Client for serious deployments.
  • Each version of Oracle database has an associated Oracle Client. As well, different major and minor versions of the database may require different versions of the client. This is my recommended approach, as it also installs many tools useful for accessing Oracle database like SQL* Plus.
  • Each version of the client also has associated extensions and drivers. For example, Oracle ODBC Driver. After you install Oracle Client for your specific version of Oracle, you may need to install the specific driver for your client. For example, Oracle ODBC for Oracle 11g.
After you install Oracle Client you will need Oracle Data Access Components. ODAC is an umbrella term for various Oracle drivers, among them ODBC.

Navigating the Oracle website is not like using Google and finding the download link. For starters, all the download links are gated for username and login so you won't find them with a simple Google search. Next, you may be looking for Oracle drivers or information out of date. As of January 2014, only Oracle 11g and Oracle 12c are available on the website. Luckily, Oracle 11g supports down to verson 9.2.0.8 when it comes to their client. If you need older versions your employer will have to have a long term contract with Oracle to provide specialized support.

Luckily, the Oracle website is well designed. Simply go to the database download section click on the version you want (as of this writing 11g and 12c are available) then click on the "See All" section beside the architecture you need (either x86 or x64). Legacy applications often need x86 so download x86 first if in doubt. Buried deep under the list of Oracle downloads for that version will be "Oracle Client."

Oracle client needs to be installed to connect to Oracle. Download and custom install Oracle client, installing everything you need.

After Oracle client has been installed, download and install Oracle Data Access Components. This will install drivers, most notably ODBC that you will need to connect to legacy applications like ADO. Certain versions of ODBC driver (for example for Oracle 9.2) require that you run command line programs in elevated mode.

After you install ODAC, you will need to do the standard work to configure the System DSN name to point to Oracle Client. This involves modifying the tnsnames.ora and listener.ora . If you installed Oracle Client properly, tnsnames.ora will be configured correctly and properly for you at the start. You will need the usual information (service name, host name, username, password) to connect to the given Oracle database. If the Oracle database is not correctly configured then you will not be able to connect. Configuring the Oracle database itself is out of scope of this blog post and you should contact your DBA or other sources if that's what you need. Check that listener.ora is correctly configured to allow NTS and EZCONNECT.

The final step for legacy connections like ODBC is to configure Windows correctly. This involves setting up ODBC with odbcad32.exe. Remember that ODBC is located in two places in Windows, in system32 and in SysWOW64 folders. Use the SysWOW64 folder to get the 32-bit ODBC (yes, that's correct).

Finally at long last you have the connection string. Make a small ASP.NET application to test the connection. Oracle has its own specific format for connection string. Always use up-to-date vendor documentation when it comes to issues like this. If you used the TEST option when installing Oracle client and when configuring the ODBC then this will be relatively painless. ODBC must be working and the client must be working before this step.

As a final note, you will need Oracle SQL Developer to act as a SQL Server Management Studio replacement. It doesn't have the full functionality of SSMS (for that you would need third-party tools like TOAD) but it has more than enough for a developer. You should be doing things like backups and imports and exports with the command line anyway.

I hope the above post will be helpful to those babysitting legacy applications for their breadwinning or developing new applications that need to connect to Oracle.

Sunday, January 5, 2014

Get Started with Git in Five Minutes

Hi,

Fear Git? Fear no more.

If you have five minutes and Linux Mint or Ubuntu or another Debian-based Linux, you can try Git now. Once you git, you never go back.

Install


sudo apt-get install git
sudo apt-get install meld
sudo apt-get install nano


Configure


git config --global user.name "Your Name"
git config --global user.email email@example.com
git config --global core.editor "nano"
git config --global merge.tool meld


Create First Repository

cd ~
mkdir ./projects
cd projects
mkdir ./test
cd test
touch testfile
git add .
git status
git commit -m "Initial commit of test file for tutorial!"
 
Done!

Further Steps

Proper introduction to git with the git book
Signup for Bitbucket for free private git repos and push repo to Bitbucket
Signup for Github and push useful piece of open source code to your profile
Change core.editor and merge.tool to your favourite editors like Sublime3 or KDiff

Wednesday, January 1, 2014

Thoughts on Bitcoin and Why I Bought Peercoins from Vault of Satoshi December 30th 2013

http://upload.wikimedia.org/wikipedia/commons/5/50/Bitcoin.png

Hi,

By now everyone has heard about Bitcoin and are kicking themselves for not buying thousands when they were under a penny.

I was kicking myself, but I wasn't too worried.  I'm a student of history and economics, and I understand the purpose and reason for currency. And it's not to hoard value or appease American libertarians who hate the Federal Reserve. The purpose of a currency is to act as a medium of exchange superior to simply bartering goods. I believe that's common ground that all types and stripes of political beliefs will agree with so that's where I'll start.

So I wanted to understand the reason for the success of Bitcoin and alternative coins (altcoins) and articles from economists, columnists and forum dwellers seemed to fall into several camps:

1. Those who dismissed the utility of Bitcoin outright. I admit I find their arguments initially persuasive, like the comparison to the Tulip bubble of 1637. People who ignore history are foolish. However the comparison is specious. Tulips wither and die and are not easily transported and impossible to divide. They can't be used as currency. The closer comparison is with Gold or other precious metals. Gold might be a several thousand year bubble until we invent cheap space travel and mine the asteroid belt, but I doubt anybody cares if anything is a bubble unless it will pop within their lifetimes. So I formulated the first of my criteria whether Bitcoin or alternate coins are worth investing in : not whether it is a bubble, but whether the bubble will pop within my lifetime or whether I can exit quickly and pocket a decent sum.

2. Those who dismissed the security of Bitcoin due to major hacks of popular Bitcoin websites. At least 30% and perhaps 50% of Bitcoin wallets fail within the first few years and some take their client's Bitcoins with them, virtual theft. Since I'm a programmer this was where I feel most comfortable commenting on. Most of the major Bitcoin hacks and scams were due to people storing their Bitcoins in an online wallet, not because Bitcoin itself is insecure. As well, it is theoretically possible (though it would require the resources of the FBI or similar government agencies) to enumerate the Bitcoin transactions and trace them to their address. Whether that will ever be done remains to be seen given the ineptitude of law enforcement when it comes to computers, but if Bitcoin ever hits mainstream government will definitely pour resources into understanding and tracking Bitcoin transactions. Anonymity is not a serious concern of mine, and I have professional computer skills. If the coins are stored online in any way shape or form it would be unacceptable to me; if major companies like Sony or the DoD could get hacked then any website-of-the-day made by some unknown web programmer could get hacked. Web programming is very hard to get right and determined hackers can always breach security. On top of that, what's to stop a web programmer in a third world country from closing shop and stealing the coins? So I formulated the second of my criteria: if Bitcoin or altcoins could be stored offline, and not in online wallets, they would be ultimately as secure as carrying cash for me personally.

3.  Those who dismissed Bitcoin due to moral reasons. I find these arguments unpersuasive. I might not agree with or even sympathize with libertarian's concerns about the Federal Reserve or the banking system (my political beliefs are far closer to Krugman's than Internet libertarians who love Ron Paul) yet Bitcoin was not originally designed by nor does it entirely benefit libertarians. Yes, Bitcoin allows you to game the system and lie about taxes or buy drugs or guns, but the FBI's bust of Silk Road earlier this year proves the government can and will catch those who use Bitcoin illegally just as they catch criminals who use cash illegally. As for Bitcoin promoting the downfall of the Federal Reserve system, if I truly believed that I would be telling everyone to avoid Bitcoin like the plague. Of course Krugman was tongue-in-cheek and probably not serious, but there are definitely people who avoid Bitcoin because of moral reasons. I give them this food for thought: Bitcoin liberates citizens in countries where the government is not democratic and has no separation between fiscal and monetary policy. If your government is going to restrict you from moving money out of the country like China does or if your currency can't hold value long enough to make a purchase then Bitcoin is freedom. I will not argue whether the USA or Western countries do this (that dives into politics far too much for a tech blog) but suffice it to say Bitcoin is only as "evil" as the people who use it. So I formulated the third of my criteria: I will only buy Bitcoin or altcoins from a legitimate company where I can be sure the coins wouldn't go to help organized crime or criminals.


One nagging moral issue is that Bitcoin is a "pump and dump" scam and that those who got in first have the most and those who got in last and/or leave last will be left holding the bag. This would be true, except for the fact that the idea of Bitcoin, circumventing government control and fast transactions, has intrinsic value in of itself. There will always be black markets and dictatorships, and there will always be a need for sending money in a blink of an eye (well, 10 minutes in the case of Bitcoin since you need to wait 10 minutes for six network confirmations) so Bitcoin has real world value. So long as these two prerogatives exist, need to move money quickly and need to avoid repressive government, Bitcoin will have a market. Day traders could pump and dump all they want, but in the end the price would come back up because unlike a company whose products are inferior or service is terrible, these two ideas are not going away. So I formulated the fourth of my criteria: I will only buy Bitcoin or altcoins with the knowledge that certain beliefs and political conditions give people a reason to hold that coin. If it isn't being held by people to solve real world problems (not crypto problems) then I won't touch it. Any altcoin such as Peercoin would have to meet that criteria as well. That means that altcoin of the day (Google PhenixCoin and see how people were scammed) that wasn't being held by Chinese venture capitalists but only held by day traders or US libertarians probably doesn't qualify.


So, if I was to buy Bitcoins, it would have to meet all of the above strict criteria (no compromises).

For the last point I found Vault of Satoshi. It is a Canadian company which opened in the last year and currently sells BTC, LTC and PPC (Bitcoins, Litecoins, Peercoins). I knew this was caveat emptor. Sending unknown people money over the Internet is not a good idea folks. You never know who you're dealing with or whether they could run off with your money. But several things made me change my mind. First, the website lists the names and photos of their staff. Second, I found nothing but glowing reviews for Vault of Satoshi and especially in the reddit.com/u/peercoin forum. Reddit, for those of you who don't know, is a grassroots Internet website for news, opinions and other things. Millions of people read it everyday and if you want to get the pulse of Internet opinion (at least in English) Reddit is the place to be. It's completely unfiltered and NSFW, but I figured that if Vault of Satoshi was a scam redditors would have indicated problems long ago. Finally I saw the volume of money going through VOS and figured that I would be small potatoes. I would only be vulnerable as long as I had the coins online on their exchange. As soon as I downloaded the coins to my offline wallet, I would not be vulnerable. It wouldn't matter if VOS really was a scam -- they would have to scam at the exact instant I chose to buy my puny amount of coin. So I would be vulnerable for a matter of days or hours only. The fact I could take them to small claims court and they were located in a Western country also assuaged my fears.

All these precautions and beliefs were unnecessary though. Vault of Satoshi has been nothing but professional to me, and indeed they answered e-mails sometimes within hours or minutes. When I wired the money to them, I was asking questions over e-mail and they answered almost immediately. Their confirmation process requiring two forms of identification is standard bank practice in Canada and I believe it is done so VOS can protect itself against regulators if accusations of money laundering arise. I wired my money from a major location in Toronto and it was confirmed and ready for trading on VOS on the same day within a few hours. That seriously impressed me and I'm pretty sure some exchange in god-knows-whatistan country overseas on holiday wouldn't even bother to check my e-mails or questions for days or weeks at a time and perhaps hold my money up for weeks as well. As of January 1st, 2014 [remember caveat emptor -- do Google searches and Reddit searches on Vault of Satoshi if you are reading this post later as it may be out of date, who knows VOS could turn into a scam site two years from now] I recommend using Vault of Satoshi for all your BTC / LTC / PPC needs even if it's a hassle to setup and the volume is low compared to other exchanges (the amount of PPC selling is extremely low and I was lucky to find the volume I needed). Their customer service is superior, their web interface is superior and the overall experience is superior.

That was the financial aspect of security.

Finally we come to computer security. This has been a long post and I've talked a lot about non-technical details. I took extreme precautions to secure my computer long before I even thought about buying any Bitcoins or altcoins. These included:

1. Wiping my hard disk and installing Linux. I will not get into the details of whether Linux is more or less secure than Windows. However it made sense for me (for other reasons) to install Linux.

2. Creating a special virtual machine for coins. This virtual machine does only coins, all coins and nothing but the coins (no surfing forums for coin news to be vulnerable to XSS attacks, no watching Youtube, no nothing). I run nothing on the host machine and everything in VMs. That is the equivalent of sandboxing almost everything. This is not convenient for anyone who needs Windows or does computer gaming (I do very little). So I may write an article about how to do this all on a Linux Live CD. But the idea is the same -- run everything off a freshly installed operating system with all the updates and patches installed and no history of third party software.

3. Creating secure passwords that are memorable and long for all my e-mail accounts, VMs, operating system and so on. Never the same one. Made long through words with letters, numbers and symbols spaced between.

4. After I bought the coins, I burned not only the wallet.dat or coin files, but the entire VM onto removable media. I made sure to lock the wallet and keep it stored on several different types of media (hint: do NOT use flash media, it's incredibly unreliable) to stand the test of two or more years. I kept the passwords separate in safe locations.

This post has been rather long and I'm growing tired. I may write a second or third post going into why I selected Peercoin, and about the exact technical details of buying Peercoins/Litecoins/Bitcoins from Vault of Satoshi (a step by step tutorial) if there is demand. One last word of warning -- most altcoins are pump and dump scams. Do not let regret over Bitcoin stop you from investigating altcoins. At this moment I do not recommend anyone who isn't incredibly computer savvy (to the level of installing your own Linux and using kvm or Virtualbox at least) nor do I recommend anyone invest any money they aren't willing to lose. It takes a great deal of research and knowledge about the technical innards of the various coins to know which are worth investing in for the short term and/or long term and which are pump and dump scams. I believe that Peercoin is not a pump and dump but without going through the source code personally I am basically taking the word of Sunny King (inventor of Peercoin and Primecoin) and his forums. The people who got stiffed by Madoff probably thought the same way.

So, have fun, play safe and remember even if you did cash in on Bitcoin early on it probably wouldn't have been enough to let you retire early or even change your life. So you didn't really miss much, just another LCD TV or car or house or two (hopefully you already have a place of residence and are not homeless; you probably already have a car too and you probably have a TV!). All toys in the big scheme of things.

My next post about crypto, should there be demand, will be a step-by-step tutorial how to buy Peercoins/Litecoins/Bitcoins securely from Vault of Satoshi.