Tuesday, March 24, 2015

Registering a listener for changes in network connections and proxy from eclipse preferences

import org.eclipse.core.net.proxy.IProxyChangeEvent;
import org.eclipse.core.net.proxy.IProxyChangeListener;
import org.eclipse.core.net.proxy.IProxyService;
import org.osgi.util.tracker.ServiceTracker;

public class ProxyHelper
{

public void registerListener()
{
ServiceTracker tracker = new ServiceTracker(MyPlugin.getDefault().getBundle().getBundleContext(),
IProxyService.class.getName(), null);
tracker.open();
IProxyService proxyService = (IProxyService) tracker.getService();
proxyService.addProxyChangeListener(new IProxyChangeListener()
{

@Override
public void proxyInfoChanged(IProxyChangeEvent event)
{
// TODO: your action for proxy changed
}
});
}

}

Sunday, March 22, 2015

Tool for checking MD5 and SHA1 values for any file

Git: Updating a forked repository from the original repository

Let's take a scenario:

This is the remote repository: https://github.com/apache/mystudio.git
Your forked repository from the above:  https://github.com/kolipakakondal/mystudio.git

'development' is the branch name both in remote and forked repository.

1. Add remote repository to forked repository
>git remote add upstream https://github.com/apache/mystudio.git

2.  Fetch from remote repository .i.e upstream
> git fetch upstream

3. Rest your branch(ex: development) to the remote branch(ex: development)
> git reset --hard upstream/development

4. Pushed changes which we got it form remote repo to remote forked repo.
> git push origin  development --force






Friday, March 20, 2015

Debugging an Installer Plugin


Step 1 : Configure your Xcode project

1Open your plugin project in Xcode.
2Choose Project > New Executable…
3Click Choose.
4Select Installer.app.
You can find Installer.app in /System/Library/CoreServices on Mac OS X 10.5 (or later) and in /Applications/Utilities on earlier versions.
5Click Finish.
6Choose Project > Set Active Build configuration > Debug.
7Choose Build > Build.

Step 2 : Debug

1Add breakpoints in Xcode
2Copy your plugin into the Plugins folder.
3Choose Debug > Debug Executable in Xcode.
4Open your package with Installer.app.


Product->Scheme->Edit scheme -> 
This will launch below screen








Wednesday, March 18, 2015

How to identify mac os Eclipse is 32 bit or 64 bit ?

These are the flags you can look at to identify whether your Mac Eclipse is 32 bit or 64 bit ?

Navigate to this menu:
Eclipse ->About Eclipse -> Click on "Installation Details" -> Click on "Configuration" tab->

And look for these parameters:

macosx
-ws
cocoa
-arch
x86_64

Here x86_64 represents 64 bit eclipse.

For 32 bit eclipse, you will find only x86. 
macosx
-ws
cocoa
-arch
x86


There are few more parameters that also represent the same.
org.osgi.framework.processor=x86-64
osgi.arch=x86_64

Upgrade node.js via npm

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

This will install the latest stable version.

If you want to install a specific version.
sudo npm n 0.10.34

This will install 0.10.34 version.

Just to cross check, use below command. This will print the installed version.
node -v

Tuesday, March 17, 2015

Friday, March 13, 2015

Breakpoints are not working with Xcode 6

There are many reasons for this.

Please check this:
http://stackoverflow.com/questions/64790/why-arent-my-breakpoints-working

In my case what worked for me is:
Click on the Xcode project-> Build Settings ->Build Options -> set "Debug Information Format" as "DWARF with dSYM File".

This is in Xcode 6.1

Thursday, March 12, 2015

Removing node.js and npm from mac os x

  1. Go to /usr/local/lib and delete any node and node_modules
  2. Go to /usr/local/include and delete any node and node_modules directory
  3. check your Home directory for any local or lib or include folders, and delete any node or node_modules from there
  4. Go to /usr/local/bin and delete any node and npm executable.
  5. If you have installed in any other custom directory, please remove that as well.

Use below command to remove recursively.
>sudo rm -rf node
>sudo rm -rf node_modules


rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}

Friday, March 6, 2015

Pulling your co-worker forked remote branch


> git remote add coworker https://github.com/coworker/studiorepo.git
> git fetch coworker
> git checkout --track coworker/foo

This will setup a local branch foo, tracking the remote branch coworker/foo. So when your coworker has made some changes, you can easily pull them.


> git pull
> git checkout foo

This will pull the latest changes. This is especially required when you wanted to pull the code and review it directly without really disturbing own repo. This will avoid setting up one more repository as well.


Wednesday, March 4, 2015

Installing npm node_modules into custom location

> npm install --prefix <custom directory path>

Example:
> npm install  --prefix C:\MyInstallations

With this, node_modules will be created in C:\MyInstallations folder.

For reference, nice content from stack overflow.

TL;DR

You can do this by using the --prefix flag and the --global* flag.
pje@friendbear:~/foo $ npm install bower -g --prefix ./vendor/node_modules
bower@0.7.0 /Users/pje/foo/vendor/node_modules/bower
*Even though this is a "global" installation, installed bins won't be accessible through the command line unless ~/foo/vendor/node_modules exists in PATH.

TL;R

Every configurable attribute of npm can be set in any of six different places. In order of priority:
  • Command-Line Flags: --prefix ./vendor/node_modules
  • Environment Variables: NPM_CONFIG_PREFIX=./vendor/node_modules
  • User Config File: $HOME/.npmrc or userconfig param
  • Global Config File: $PREFIX/etc/npmrc or userconfig param
  • Built-In Config File: path/to/npm/itself/npmrc
  • Default Config: node_modules/npmconf/config-defs.js
By default, locally-installed packages go into ./node_modules. global ones go into the prefix config variable (/usr/local by default).
You can run npm config list to see your current config and npm config edit to change it.

Resources:
http://stackoverflow.com/questions/14742553/npm-local-install-package-to-custom-location

Tuesday, March 3, 2015

How to extract files from msi file

Type in below command.

Syntax:
msiexec /a filepath to MSI file /qb TARGETDIR=filepath

For example:

msiexec /a C:\kondal\node-v0.10.13-x86.msi.exe /qb TARGETDIR=C:\kondal\test

Monday, March 2, 2015

GIT: some useful git commands for my reference

To delete a local branch:
> git branch -d <branch name>


To checkout to remote branch
> git fetch
> git checkout <branchname>