Java - Get Command Line Parameters

15/07/18 Permalink

I couldn't find a simple way of parsing command line parameters passed to programs without needlessly importing libraries. String[]args is parsed using spaces only, so if you want more advanced parameters were you name the values and have multiple values like java Prog -opt0 blah blah2 -opt1 blah you'll need to parse it yourself.

Here's a simple way of doing more advanced command line parsing in Java:

 public HashMap<String,ArrayList<String>> getCommandLineOptions(String[]args){
   	HashMap<String,ArrayList<String>> opts = null;
        String opt = null;	
	for(String arg:args){
	   	if(arg.startsWith("-")){
	   	      opt=arg;	   					
	   	}else if(opt!=null){
		      ArrayList oopts = opts.get(opt);
		      if(oopts==null){
			  oopts=new ArrayList();
		      }
		      oopts.add(arg);
		      opts.put(opt,oopts);
		}
	}
	return opts;  			
  }

Android - Change Project Target API

07/01/17 Permalink

To use a different API library to build with in Android use the following method:

android.bat update project --path . --target "android-8"

And to see what API libraries are available:

android list targets

Multiple HTML Checkbox Selector

31/10/16 Permalink

Here's a simple way to quickly select all checkboxes on a webpage. Just drag the following link onto your Bookmarks Toolbar (works on Firefox, should work on Chrome)

Check All

It works by scanning the checkboxes on the current webpage and checking them, followed by void(); to prevent a new page loading.

Raspbian Keyboard Keys Not Repeating

15/09/16 Permalink

I had a strange problem with Raspbian GNU/Linux 8 (jessie) whereby the keys wouldn't repeat when pressed down. The solution was to restart auto-repeat with xset:

xset r off
xset r on

A Simple One-Line EU Cookie Consent Script

18/08/15 Permalink

The EU directive says that all websites that use cookies and have EU visitors must put up a cookie consent form for their user.

And here's a simple one line javascript for webmasters to use for free (ironically, it uses a cookie):

<script src="http://js.mobile-utopia.com/js/eucookie2.js"></script>
Products/Projects Categories Bookmarks Device Manufacturers

mobile-utopia.com | Feedback