Compile & Run Java within Sublime Text 3

Build script for Sublime Text to compile & run the Java file within Sublime Text.
You can create new build script as below:

Sublime Text Custom Build System
Sublime Text Custom Build System

Before executing build, you need to save your Java file.

By default it’ll compile & run your Java file.
But you can perform individual task with the following commands:
1) Compile Java
2) Run Java

{
    "cmd": ["javac", "-Xlint", "$file"],
    "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
    "selector": "source.java",
    "cmd": ["java", "$file_base_name"],
    
    "variants": [
        {
            "cmd": ["javac", "-Xlint", "$file"],
            "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
            "selector": "source.java",
            "name": "Compile Java"
        },
        {
            "cmd": ["java", "$file_base_name"],
            "name": "Run Java"
        }
    ]
}

Issue Opening Context Menu from Notification Area in Taskbar

Story starts as follow…

I am using a program, which runs in background & doing its job.
In case I want to change any settings, the only way I can do, is from its context menu.. which can be accessed by clicking its Icon, from the Notification Area of Taskbar. In fact, I can close this program only from that context menu…

I am using this program from almost last 1 yrs.. And all of a sudden, it stops displaying the context menu! Where it allows me to change settings, as well as to close the program. And I had no idea how to solved it! I tried to forcefully close the program from the Task Manager.. tried to restart my PC.. But no luck.. then I contacted its developer, but we didn’t get a clue, whats going on! Then today finally got the solution… Issue as I explained is really very strange, but the the solution is also a bit tricky & can’t be easily catch-able!

Under  \Windows\Prefetch folder I found 3 files which starting with the same name & with extension of “.PF”. I deleted those files & booom.. Everything is back to normal.. I am able to see context menu & can change settings.. As well as I can properly close the program..

You can get some details about  \Windows\Prefetch folder at “Wikipedia

So how do I found this issue ?!?!
Well every-time when I am running my program, Antivirus will scan all the files associated with that program. And that’s where I found its scanning a file from Prefetch folder..

I am not sure whether it’s right solution or not, but I managed to get rid of the issue…

 

 

Share Internet Across All Devices @ Home/Office using 3G USB Stick (Adapter/Dongle/Data Card) & WiFi Router

This post is for those who are using 3G USB Dongle (Tata Phone+, Airtel 3G Stick, BSNL 3G Stick etc…), without inbuilt support of wireless connection, but they still want to use the same connection across all the WiFi supported devices @ home/office.

Let me tell you why I need this… I am having couple of devices like two laptops, PS3, iPod, Android Phone and an Android tablet… All these devices can connect to WiFi network. But I am using 3G USB Stick which I can use only in my laptop and that’s why I want to create a network by which I can share my internet in all my devices.

First easiest option is I can create an Ad-Hoc connection in windows. But drawback is PS3 & Android devices are not able to connect to this Ad-Hoc connection.

Now the second option is we use ICS (Internet Connection Sharing) by mapping 3G Stick connection with wifi adapter of laptop/desktop by setting following configurations. So at the end we’ll have something like:

3G USB Adapter + WiFi Router Setup
Share Internet using 3G USB Adapter & WiFi Router

Extending ArrayCollection to Implement Inbuilt Filter Functionality

Now a days many of the data-centric Flex (Flash Builder) applications are using DataGrid/AdvancedDataGrid. DataGrid is a one of the powerful component in Flex.

I’ve executed couple of projects around these components, where I used to implement search functionality (filtering data based on certain criteria). In order to simplify filtering, I’ve created custom class around ArrayCollection (which we’re extensively using for dataProvider), which will help to reduce a bit of code for me…

Limitation of this code is, we can only add single column criteria for filtering data.
e.g. in one criteria would be dataField=”name” & filterValue=”Some Keyword”, second would be growth=”30″ likewise.. what we can’t add is something like multiple fields in single criteria, “dataField”=”name, growth” & filterValue=”Some Keyword”.. Also we can not do any conditional search, e.g. value>10..

Attached code will produce following result.
[SWF]http://chintanbuch.com/wp-content/uploads/2011/08/arraycollection_filter_1.swf, 250, 300[/SWF]

There are two classes, which we need to use in order to implement search capablity:

FilterCriteriaVO:

1
2
3
4
5
6
7
8
9
10
11
public class FilterCriteriaVO extends Object
{
	public var dataField    :String;
	public var filterValue  :*;
	public var exactMatch   :Boolean;
 
	public function FilterCriteriaVO()
	{
		super();
	}
}

ArrayCollectionEx:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
public class ArrayCollectionEx extends ArrayCollection
	{
		/**
		 * This array will have "Data Field of Column", "Filter Value" & "Exact Match Flag" pair
		 * - "Data Field of Column" is on which we want to filter
		 * - "Filter Value" with what we want to filter
		 * - "Exact Match Flag" will check for the exactly matching value, instead of part of value
		 * */
		public var dataFilterCriteria	:Array = new Array();
		private var strFilterItemValue	:String;
		private var strFilterFor		:String;
 
		public var customFilterFunction:Function;
 
		public function ArrayCollectionEx(source:Array=null)
		{
			super(source);
			filterFunction = dataFilterFunction;
		}
 
		protected function dataFilterFunction(dataValue:Object):Boolean
		{
			if(dataFilterCriteria.length < 1) {return true;}
			if(customFilterFunction != null){return customFilterFunction(dataValue);}
 
			var filterMe:Boolean;
			var dataItem:Object = dataValue;
			if(dataFilterCriteria.length > 0) {
				for(var i:int=0; i<dataFilterCriteria.length; i++) {
					if((dataFilterCriteria[i] as FilterCriteriaVO).exactMatch) {
						if(dataItem[(dataFilterCriteria[i] as FilterCriteriaVO).dataField] == (dataFilterCriteria[i] as FilterCriteriaVO).filterValue)
							{filterMe = true;}
						else	
							{return false;}
					} else {
						strFilterItemValue = (dataItem[(dataFilterCriteria[i] as FilterCriteriaVO).dataField] as String).toLowerCase();
						strFilterFor = (dataFilterCriteria[i] as FilterCriteriaVO).filterValue.toLowerCase();
						if(strFilterItemValue.indexOf(strFilterFor) > -1)
							{filterMe = true;}
						else
							{return false;}
					}
				}
			}
			return filterMe;
		}
 
		public function addFilterCriteria(filterCriteriaVO:FilterCriteriaVO):void
		{
			if(dataFilterCriteria.length > 0) {
				var foundSimilarCriteria:int = checkForItemInCriteria(filterCriteriaVO.dataField)
				if(foundSimilarCriteria > -1) {
					(dataFilterCriteria[foundSimilarCriteria] as FilterCriteriaVO).filterValue = filterCriteriaVO.filterValue;
					this.refresh();
					return;
				}
				dataFilterCriteria.push(filterCriteriaVO);
				this.refresh();
			} else {
				dataFilterCriteria.push(filterCriteriaVO);
				this.refresh();
			}
		}
 
		public function removeFilterCriteria(filterCriteriaVO:FilterCriteriaVO):void
		{
			if(dataFilterCriteria.length > 1) {
				var foundSimilarCriteria:int = checkForItemInCriteria(filterCriteriaVO.dataField);
				if(foundSimilarCriteria >= 0) {
					dataFilterCriteria.splice(foundSimilarCriteria, 1);
					this.refresh();
				}
			} else if(dataFilterCriteria.length == 1) {
				dataFilterCriteria = [];
				this.refresh();
			}
		}
 
		protected function checkForItemInCriteria(dataField:String = null):int
		{
			var foundSimilarCriteriaAt:int = -1;
			for(var i:int=0; i<dataFilterCriteria.length; i++) {
				if((dataFilterCriteria[i] as FilterCriteriaVO).dataField == dataField) {
					foundSimilarCriteriaAt = i;
					break;
				}
			}
			return foundSimilarCriteriaAt;
		}

Source Files