RSS

XCode smartly finds your project if you move it

Recently I had to re-organize some of my Xcode projects. So I renamed the folders and opened Xcode. To my surprise Xcode knew the new location of my project. Thats cool!!

 
Leave a comment

Posted by on February 18, 2014 in Uncategorized

 

How to change Printer password in OSX

At my work I use a Mac in a Windows environment and once in a while I need to use a printer. Today when I needed to print something it did not work. The print queue showed that authentication was needed. I remembered that the Windows domain had forced me to change my password. So I started searching for a place where I could change the password for the printer.

It seems its not very obvious at first and Googling suggested editing some files related to CUPS. I wasn’t very comfortable with it but I started to play around and then I thought about the Keychain. So here is one of the two ways you can change the password.

Method 1:

1. Go to Spotlight and search for Keychain
2. Select “Passwords” in the left pane
3. In the top right corner search for printer name
4. Double click on the for your printer. The “Kind” column should say “network password”
5. Check the “Show Password” checkbox
6. Enter your OSX login password if prompted
7. Now change the password to new password and click “Save Changes”
8. Now try printing

Method 2:

1. Go to Finder
2. From the menu Go -> Connect to Server
3. Provide the exact same URL that you had given when connecting to the printer.
If you are not sure of the URL used you can find it by running the following command from Terminal

sudo cat /etc/cups/printers.conf

Look for your printer name and a line starting with DeviceURI. Use only the beginning part of the URL which should be of the form

smb://<server name/IP Address>

4. Hit Connect and provide the new username and password
5. Now try printing

 

 

 
Leave a comment

Posted by on August 27, 2013 in OSX, Uncategorized

 

Common Git commands

In my previous post last month I described the migration from SVN to Git. Since then I have been using it in my project. This post is about the typical workflow and how it can be achieved in Git.

1. Getting code

mkdir <dirname>
git init
git pull <repo URL>

This will pull the remote repository on your machine. The URL can be HTTP/HTTPS or SSH. In case of SSH you will need to generate a key pair first.

2. Seeing what has changed

git status

Shows the current branch you are on and the staged and unstaged changes.

3. Committing Changes

git commit -a -m <commit message>

Commits all the staged changes.

4. Pushing commits

git push

Push all commits to the remote repository

5. Storing current changes and going back to HEAD

git stash save <stash name>

All current changes are stashed away in a temporary area and resets the current branch

6. Restoring previously stored changes

git stash apply <stash name>

Merges the stashed changes back into the working copy

7. Create a new branch

git branch <branch name>

8. Switch to another branch

git checkout <branch name>

9. Merge branch with master

git checkout master
git merge <branch to merge>

10. Cherry pick changes from another branch

git cherry-pick -e -x <commit>

Pick specific commits, maybe from another branch, and apply to working copy

11. Tagging

git tag <tag name>

If you are new to Git you will find the Git GUI to be very handy. However, it does not support all the git commands such as stash. I always end up using both the command line and GUI at times when I get a bit lazy.

 
Leave a comment

Posted by on June 24, 2011 in Git

 

Moving from SVN to Git

I have been playing around with Git for a while now and its a great tool. The workflow is so much development oriented. So recently I decided to move one of my projects from SVN to Git, actually GitHub to be more specific. This post here details the steps in the process and lists some things to look out for. It assumes a basic understanding of Git. The Official Git Tutorial page is a good place to start. I found this talk by Linus Trovalds very insightful.

1. Register with GitHub

If you want to centrally host you Git repository on a server you can use GitHub. Its an excellent service for Git based projects with lots of features. It allows you to have both public and private hosted repositories. 

2. Clone the SVN repository

The first step in the process is to clone the SVN repository to a local Git repository. To do this run the following command

git svn clone -s <SVN Repo URL> <Git Repo Local Dir>

NOTE: Remove the -s option if you don’t have a standard SVN layout (tags, trunks, branches). You might need to use the --trunk, --tags, --branches options.

Depending on the size of the SVN repository and the commits in it this process might take a long time so go grab a coffee.

3. Check the Git repo

Now that the SVN repository is cloned into a  Git repository we can check the files in the new repository. Run the following command  to see commit logs. But we did not commit anything yet in Git, right? Well these are commits in SVN which Git has added into the new repository.

git log

4. Add from svn:ignore

If the SVN repository uses svn:ignore to ignore specific files, corresponding .gitignore files can be created as follows

git svn create-ignore
git add .
git commit --message "Committing gitignore files"

If the repository is to be published on a central server then proceed with the next steps otherwise you can jump to the What Next? section.

5. Push the Git repository to GitHub

You now have a local Git repository, ready to be pushed onto the GitHub server. But first things first. Generate a public/private keypair by following either of these guides based on your OS  Set Up Git (Windows)  and Set Up Git (Linux)

git remote add origin <SSH Git URL>
git push -u origin master

The SSH Git URL can be found by selecting the Git repository in GitHub and looking at the header as shown below

What Next?

Now you are all set and can start making changes to to your code and using the wonderful features of Git. But before that a few things to remember and understand.

  • Git does not track individual files but the contents
  • Git cannot have empty folders
  • A commit operation in Git commits to the local Git repository not the central repository. If you want to push it to the central repository then use git push.
  • Always run git status and git add before doing any commits to ensure that any new files are added. Alternatively you can use the -a switch in Git commit along with  the --interactive switch
  • Use branches whenever making changes. Its way too easy and a very central feature of Git.
  • Use git stash to store your changes into a working directory in case you need to restore to another branch temporarily.
 
4 Comments

Posted by on May 24, 2011 in Git

 

Eclipse 3.6 (Helios) – A quick look

The Eclipse 3.6 (Helios) release is nearing and as always its pretty exciting. The 3.x releases have all added a lot of features which make Java and J2EE development much more easier, exciting and fun. So I decided to try it out and write about some of the new features it has. I primarily use Eclipse for J2EE so my review is more focussed on JDT and Java related features.

Eclipse Marketplace

A cool new feature which allows access to online marketplaces  like Eclipse Marketplace, Yoxos Marketplace to get tools, and plugins. Before 3.6 one would have to go to the plugin’s site, get the update site URL, and then go into Eclipse to install it. With 3.6 all of that can be done from within Eclipse provided the plugin is available in the marketplace catalog. This feature can be accessed from Help -> Eclipse Marketplace.

Export Preferences

The Export preferences wizard now provides additional options to export code style preferences and compiler preferences.

JDT Enhancements

  1. Quick Fix now allows fixing multiple instances of a problem
  2. A new command allows opening of implementations for overridable methods, which can be accessed either by selecting text or from Navigate -> Open Implementation
  3. Java formatter can now selectively format code sections demarcated with formatting flags. There are two flags one to turn it on and another to turn it off. They need to be enabled from the “Off/On Tags” tab of the formatter preferences.
  4. Several enhnacements to the Java Formatter related to formatting of annotations, nested method calls, and block comments.
  5. Missing @Override tag is now reported by the compiler, for 1.6
  6. Unused objects are now detected and Quick Fix is provided
  7. Build path errors in project are now shown with a decorator in Package Explorer
  8. Package names can be abbreviated. They can be configured from preferences page under Java -> Appearance
  9. Call Hierarchy allows removing of one or more nodes
  10. Type Hierarchy is now computed in background. This is very helpful particularly when trying to lookup a type in a large hierarchy.
  11. The Variables View can show the instance count of variables by selecting Layout -> Select Columns from the views menu
  12. The Breakpoints view now shows the a Breakpoint Details pane with the breakpoint properties which can also be modified

There are several more but this is it for now

 
2 Comments

Posted by on June 15, 2010 in Eclipse, Helios

 

MyEclipse and JBoss Tools

I have been using MyEclipse for all my Java development. Its a great IDE and I cant really think of working on a Java project without it. For a project I had to evaluate RichFaces and figure out the best IDE environment for developing the UI. My previous experiences with JSF were not that great and I would not consider at JSF until I looked at RichFaces. Both JSF and RichFaces have evolved. So I wanted to see how I could develop with RichFaces using my favourite IDE MyEclipse and thats where my problems started.

It turns out that MyEclipse and RichFaces dont play too well, or for that matter any of the JBoss Tools plugins. At first I could not understand why. I mean both work with the same version of Eclipse and same versions of plugins like WTP, TPTP, EMF etc. Besides OSGi, p2 equinox should make plugins work seamlessly. But its not that simple. MyEclipse and JBoss have some long-standing differences. Number of MyEclipse users have been sending feature requests since 2007. However, this has not been resolved to date and there is no commitment to resolve this. One of the posts was posted in Jun 2009 and it got a reply asking to add a feature request.

Its looks like both of them wont budge. I think they should think about their users and sort this long-standing issue. Both are great tools and it would immensely benefit the community and also help JSF, and RichFaces if both these tools interoperate. Without this developers using MyEclipse will have no choice but to use JBoss Tools for developing with RichFaces or maybe choose ICEFaces as MyEclipse has built-in support for that. But using RichFaces with MyEclipse is cretainly out of the question, unless you are okay with just using the basic JSF editing without any darg-drop designing.

I welcome any suggestions and would be interested in knowing how you have got around this issue in case you use RichFaces and have MyEclipse.

 
Leave a comment

Posted by on September 5, 2009 in JBoss, MyEclipse, Richfaces

 

Tags: , ,

Custom Metdata in Alfresco Share

I recently setup Alfresco 3.0 Community for internal usage. I was able to get everything running with LDAP and NTLM integration. The Share application however, needed some tweaking as I had added some custom types and Share does not display custom metadata as of 3.0. So instead for going for the 3.1 Preview, which has forms support I decided to stick to the more stable 3.0 and tweak it. In this post I will describe the changes required.

I recently setup Alfresco 3.1 Community for internal usage. I was able to get everything running with LDAP and NTLM integration. The Share application however, needed some tweaking as I had added some custom types and Share does not display custom metadata as of 3.1. So instead for going for the 3.2 Preview, which has forms support I decided to stick to the more stable 3.0 and tweak it. In this post I will describe the changes required. Please note that this post applies only to Alfresco 3.1 Community. Alfresco 3.2 adds forms support which provides support for any custom metadata to be displayed/edited with very minimal configuration.

First you need to tell the Web Framework to show your custom type by adding the following in web-framework-config-custom.xml in the web-extension folder.


<config evaluator=”string-compare” condition=”my:customtype”>
<form>
<field-visibility>
<show id=”my:prop1? />
<show id=”my:prop2? />
</field-visibility>
<appearance>
<field id=”my:prop1? />
<field id=”my:prop2? />
</appearance>
</form>
</config>

Now edit share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/document-details/document-info.get.html.ftl and add appropriate HTML for displaying the custom metadata as below


<div class=”info-section” id=”${args.htmlid}-customtype”>
<div class=”heading”>Custom Metadata</div>
<div class=”info”>
<span class=”meta-label”>Prop1:</span>
<span id=”${args.htmlid}-prop1? class=”meta-value”></span>
</div>
<div class=”info”>
<span class=”meta-label”>Prop2:</span>
<span id=”${args.htmlid}-prop2? class=”meta-value”></span>
</div>
</div>
</div>

Next, modify share/components/document-details/document-info.js to display the additional metdata. This needs to be done in the onDocumentDetailsAvailable function as follows


if (!docData.customtype)
{
var customTypeDiv = Dom.get(this.id + “-customtype”);
customTypeDiv.innerHTML = “”;
}
else
{
Dom.get(this.id + “-prop1?).innerHTML = $html(docData.customtype.prop1);
Dom.get(this.id + “-prop2?).innerHTML = $html(docData.customtype.prop2);
}

We have now made the changes in Share to display the custom metadata. But the data will still not be displayed because Share gets the data from a Web Script which also needs to be modified. To do that modify the file alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js as follows
Add the following lines inside the <#assign tags> block.


<#if item.customtype?exists>
“customtype”:
{
“prop1″: “${item.customtype.prop1}”,
“prop2″: “${item.customtype.prop2}”
},

 

Now modify the alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js file and add the following just before the items.push(…) line


var customtype = null;
if (assetType == “document” && asset.type == “{myuri}customtype”)
{
var prop1 = “”;
if (asset.properties["{myuri}prop1"])
{
prop1 = asset.properties["{myuri}prop1"];
}
var prop2 = “”;
if (asset.properties["{myuri}prop2"])
{
prop2 = asset.properties["{myuri}prop2"];
}
customtype =
{
prop1:prop1,
prop2: prop2
}
}

This should display the custom metdata in Share when you click on a document and go to the detail page. In next post I will cover how you can display the metdata in the Edit Metadata screen and also save any changes.

 
7 Comments

Posted by on July 3, 2009 in Alfresco

 

Tags: , ,

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: