Sunday, 16 November 2014

Excel / Google Spreadsheet utilities

Generate a list of sheet names in the workbook (google spreadsheets only)

- https://productforums.google.com/forum/#!topic/docs/-2mGCzmUIkY

function sheetnames() {
  var out = new Array()
  var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
  for (var i=0 ; i<sheets.length ; i++) out.push( [ sheets[i].getName() ] )
  return out  
}


Retrieving a specific cell value from other sheets

https://productforums.google.com/forum/#!topic/docs/YwfiGQpg5LI

Sheet name with no space:
=Sheet1!A1

Sheet name with space
='Sheet Name'!A1


Use string value from a cell to access worksheet of same name

http://stackoverflow.com/questions/16899175/excel-use-string-value-from-a-cell-to-access-worksheet-of-same-name

e.g. cell A5 has the string value of the worksheet name
=INDIRECT("'"&A5&"'!G7")




Tuesday, 14 October 2014

Sublime - search and replace text

Suppose I have multiple files that I want to replace the URL with something like follow:

www.something.com to
www.qa.something.com.au

Here is what to do:

Find:
www.([a-z]+).com

Replace:
www.qa.$1.com.au

Thursday, 2 October 2014

JSP/JSTL EL lastIndexOf

References
http://www.willuhn.de/blog/index.php?/archives/425-lastIndexOf-in-JSTL.html
http://www.tutorialspoint.com/jsp/jstl_function_substring.htm

Example:
<c:set var="text" value="This is a bunch of text" />
<c:set var="splittext" value="${fn:split(text,' ')}" />
${fn:indexOf(text, splittext[fn:length(splittext)-1])}

Git delete branch

Delete local branch

git branch -d [branchname]


Delete remote branch

git push origin --delete [branchname]
or
git push origin :[branchname]

The second way is basically saying "push nothing to remote [branchname]"

Git pushing local branch to specific remote branch

git push origin local_branch:remote_branch

Thursday, 25 September 2014

Sublime Text - reveal in sidebar

http://julianhigman.com/blog/2013/07/23/sublime-text-3-keyboard-shortcut-to-reveal-file-in-sidebar/

  1. Right click on the file in the editor
  2. Reveal in Side Bar.

To set a shortcut key:
  1. Preferences 
  2. Key Bindings (User)


edit the file as follow:
[
 { "keys": ["ctrl+shift+r"], "command": "reveal_in_side_bar"}
]


Wednesday, 17 September 2014

Git - remove / discard changes

If the changes have been commited to local branch but not yet push --

Reset local branch to repository:
git reset origin/develop
git reset HEAD


Remove / Discard unstaged changes:
git clean -df
git checkout -- [file]


Documentation for git clean:
http://git-scm.com/docs/git-clean

Friday, 29 August 2014

Adobe AEM/CQ - cq:Page redirect

Out of the box redirection for cq:Page type settings are as follow:


  • jcr:content
    • redirectTarget | String | /[path]/[to]/[redirect]
    • sling:redirect | Boolean | true
    • sling:redirectStatus | Long | 302
    • sling:resourceType | String | foundation/components/redirect

Thursday, 28 August 2014

Git - when to merge and rebase

http://www.derekgourlay.com/archives/428

" Rebases are how changes should pass from the top of hierarchy downwards and merges are how they flow back upwards. "


Rule of thumb:

  • When pulling changes from origin/master onto your local branch, use rebase.
  • When finishing a feature branch merge the changes back to develop.


Rebase

git pull --rebase
or
git fetch origin
git rebase -p origin/[master]


Merge

git checkout master
git merge [branch]

Monday, 25 August 2014

45 ways to avoid using the word 'very'


“So avoid using the word ‘very’ because it’s lazy. A man is not very tired, he is exhausted. Don’t use very sad, use morose. Language was invented for one reason, boys - to woo women - and, in that endeavor, laziness will not do. It also won’t do in your essays.” 
― N.H. Kleinbaum, Dead Poets Society


Wednesday, 20 August 2014

Adobe AEM/CQ - remove whitespace from generated HTML

http://www.wemblog.com/2014/07/how-to-remove-white-space-from.html

1) trimDirectiveWhitespaces
<%@page  trimDirectiveWhitespaces="true"%>

2) Use
--%><%--
tags to start and end scriplets tag and in between html tag

3) Create your own tag library and using html parser remove white spaces during run time. for that check http://www.cqblueprints.com/tipsandtricks/jsp-custom-tag-lib.html

4) Use Google Page Speed Module at apache.

Friday, 15 August 2014

Cygwin - change home directory after installation

http://stackoverflow.com/questions/1494658/how-can-i-change-my-cygwin-home-folder-after-installation

  1. Go to Control Panel --> System and Security --> System (or press the [WINDOWS]+PAUSE|BREAK] keys)
  2. Click Advanced system settings (located at the left)
  3. Click Environment Variables (toward the bottom)
  4. In the User Variables area click "New…"
  5. For Variable name enter HOME
  6. For Variable value enter %USERPROFILE%
  7. Click OK in all the open dialog boxes to apply this new setting

cp /etc/passwd /etc/passwd.bak
mkpasswd -l -p $(cygpath -H)  > /etc/passwd 
mkpasswd -d -p $(cygpath -H)  >> /etc/passwd 

cp /etc/group /etc/group.bak
mkgroup -l > /etc/group 
mkgroup -d >> /etc/group


Exit Cygwin and start it up again.

Monday, 11 August 2014

Adobe AEM/CQ - setting up Maven POM

Content Package


http://www.wemblog.com/2012/04/how-to-change-package-install-behavior.html

<build>
    <plugins>
      <plugin>
         <groupId>com.day.jcr.vault</groupId>
         <artifactId>content-package-maven-plugin</artifactId>
         <extensions>true</extensions>
         <executions>
             <execution>
                 <goals>
                    <goal>package</goal>
                 </goals>
             </execution>
          </executions>
          <configuration>
             <!-- parameters and values common to all goals, as required -->
          </configuration>
      </plugin>
    </plugins>
</build>

Note:
Need <extensions> in order for <packaging>content-package<packaging> to work

Adobe documentation:
http://docs.adobe.com/docs/en/aem/6-0/develop/how-tos/vlt-mavenplugin.html

Getting the latest content-package-maven-plugin:
http://repo.adobe.com/nexus/content/groups/public/com/day/jcr/vault/content-package-maven-plugin/


Bundle

http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
        </plugin>
    </plugins>
</build>

Adobe documentation:
http://docs.adobe.com/docs/en/cq/aem-how-tos/development/how-to-build-aem-projects-using-apache-maven.html

Checking the latest version of maven-bundle-plugin:
http://felix.apache.org/downloads.cgi#maven


Sunday, 27 July 2014

Adobe AEM/CQ - extjs multifield + compositefield with multiple textfields

Suppose we have a form (name: 'formName') with a multifield as follow:

var multifield = new CQ.form.Multifield {
    fieldLabel : 'Multiple: ',
    orderable : false,
    name : 'multifieldExample',
    fieldConfig : {
        xtype : 'compositefield',
        layout: 'form',
        items : [{
          xtype: 'textfield',
          fieldLabel: 'field1: '
        }, {
          xtype: 'textfield',
          fieldLabel: 'field2: '
        }]
    },
    width: 650
}

Here is how we can retrieve the value of the first instance of field2:

formName.getForm().findField('multifieldExample').findByType('compositefield')[0].items.itemAt[1].getValue();

We can retrieve the items under a component via .items.itemAt[i]


Monday, 16 June 2014

Adobe AEM/CQ - ACS dispatcher flush rules

We use this to flush associate paths for a given node.

E.g.
When an activation occurs for path /content/abc, we can configure with this ACS package to also flushes the dispatcher cache for path /content/xyz.

Read more about this add-on here:


Configurations:

/system/console --> ACS dispatcher flush rules










/etc/replication/agents.publish.html






Tuesday, 10 June 2014

Adobe AEM/CQ - bulk editing

http://localhost:4502/etc/importers/bulkeditor.html

This can be use to bulk edit multiple nodes that have been created in the CQ repository.

Thursday, 10 April 2014

Adobe AEM/CQ - Repository Inconsistency

http://helpx.adobe.com/experience-manager/kb/RepositoryInconsistency.html

My current project is running into some IndexNotFound exceptions which is caused by repository being inconsistent.

I ran the ConsistencyCheck as per the article in the link above but it came back with 699 unrepairable nodes.

I used the query-builder to search for one of the complaining missing node and it turns out that the culprit node(s) were from CQ itself:
1. Access http://[host]:4502/libs/cq/search/content/querydebug.html
2. Search with:
path=/content 
uuid=[complaining-missing-node]
Results:
  • /content/catalogs
  • /content/catalogs/jcr:content
  • /content/campaigns
  • /content/campaigns/jcr:content
  • /content/dam
  • /content/dam/rep:policy
  • /content/dam/rep:policy/allow
  • /content/dam/jcr:content
  • /content/dam/mac
  • /content/dam/hierarchy

So we decided to re-index the repository:
1. Stop the CQ instance
2. Rename the index directory in
- crx-quickstart/repository/repository/index
- crx-quickstart/repository/workspaces/crx.default/index
3. Start the CQ instance

The repository inconsistent related errors were gone initially, but it returned to haunt us again. So far this haven't impact any functionality or performance, but it is still a risk that it might become worst.

We are leaving it for now as we have ran out of ideas, I'll keep myself posted here.

Update 1:
Change of events, apparently the way I search the uuid in querybuilder is incorrect. The correct query to be use should be:
path=/content
property=jcr:uuid
property.value=[complaining-missing-node]

And it returns nothing from that query...

Battle continue...

Monday, 7 April 2014

Adobe AEM/CQ - bundle version comparison

http://dev.day.com/content/dam/day/onlinetool/COI.html

Thursday, 13 March 2014

Adobe AEM/CQ - Package Manager filtering

Creating a filter that excludes specific nodes relative to the filtering path.

Gmail - hidden ways to filter out emails

http://gmailblog.blogspot.com.au/2008/03/2-hidden-ways-to-get-more-from-your.html

Posted by Robby Stein, Associate Product Marketing Manager

I recently discovered some little-known ways to use your Gmail address that can give you greater control over your inbox and save you some time and headache. When you choose a Gmail address, you actually get more than just "yourusername@gmail.com." Here are two different ways you can modify your Gmail address and still get your mail:

  • Append a plus ("+") sign and any combination of words or numbers after your email address. For example, if your name was hikingfan@gmail.com, you could send mail to hikingfan+friends@gmail.com or hikingfan+mailinglists@gmail.com.
  • Insert one or several dots (".") anywhere in your email address. Gmail doesn't recognize periods as characters in addresses -- we just ignore them. For example, you could tell people your address was hikingfan@gmail.com, hiking.fan@gmail.com or hi.kin.g.fan@gmail.com. (We understand that there has been some confusion about this in the past, but to settle it once and for all, you can indeed receive mail at all the variations with dots.)

For me, the real value in being able to manipulate your email address is that it makes it really easy to filter on those variants. For example you could use hikingfan+bank@gmail.com when you sign up for online banking and then set up a filter to automatically star, archive or label emails addressed to hikingfan+bank. You can also use this when you register for a service and think they might share your information. For example, I added "+donation" when I gave money to a political organization once, and now when I see emails from other groups to that address, I know how they got it. Solution: filtered to auto-delete.

Tuesday, 11 March 2014

Adobe CQ/AEM - CQ dependencies POM

Here is an example of setting up the pom file for CQ dependencies:
http://dev.cqblueprints.com/nexus/content/repositories/releases/com/cqblueprints/cqdependencies/5.6.0/cqdependencies-5.6.0.pom

Obviously you wouldn't include everything in that file - just the ones needed for the project. I believe the order of dependencies matters too.

Wednesday, 5 March 2014

Adobe CQ/AEM - Logging configuration

Here is an example for adding a configuration to log CQ query information:

  1. Open http://localhost:4502/system/console/configMgr and scoll down to "Apache Sling Logging Logger Configuration" and click on it.
  2. In the dialog set the following
    • Log Level to 'Debug
    • Log File to 'logs/query.log'
    • Logger to 'org.apache.jackrabbit.core.query.QueryImpl'
  3. Click on save.
There should be a new entry created under Apache Sling Logging Logger Configuration

Tuesday, 25 February 2014

Adobe AEM/CQ overwriting built-in plugins for richtext editor

Example given here -
to overwrite the built-in link configuration dialog box by adding a field to set a link title:
http://forums.adobe.com/thread/1230814

Very important to compare the code given in the example for changes.

Overview:
  1. Setup in the apps director to create a "widgets" folder with these values
    • jcr:primaryType  = cq:ClientLibraryFolder
    • sling:resourceType = widgets/clientlib
    • categories = cq.wcm.edit
  2. Create a js file that overrides the built-in js plugin, note:
    • Initialize the name of the plugin
    • Register the name to the built-in xtype
    • Uses CQ.form instead of CUI.
  3. Create a js.txt and include the name of js file within



Friday, 21 February 2014

Adobe AEM/CQ seach results


Configure indexing for search:
http://helpx.adobe.com/experience-manager/kb/SearchIndexingConfig.html

Overview:
  1. Create a mapping with index to latest articles
  2. Components can retrieve articles via the mapping
  3. When new articles come in, update the mapping of index at the background
  4. Once the new mapping is complete, replace the mapping

Tuesday, 11 February 2014

Adobe CQ/AEM Query Builder - empty property

So at work, I was faced with a scenario where I have to use the CQ query builder to retrieve a bunch of articles that when they do not have a date property it will be selected along with the ones with date property that does not expire.

A little pseudo-code to show what I mean:

if (!article.hasDate) {
  return true;
} else {
  if (article.date >= now()) {
    return true;
  }
  return false;
}

Here are some articles I found online before I came up with a solution:



Finally, here is what I have in CQ query builder:

path=[path/to/articles]
type=cq:Page
99_property=@jcr:content/cq:template
99_property.value=[apps/path/to/template]
10_group.p.or=true
10_group.1_property=@jcr:content/offTime
10_group.1_property.operation=not
10_group.2_daterange.property=@jcr:content/offTime
10_group.2_daterange.lowerBound=[current-date-or-hardcode-date-for-testing]
10_group.2_daterange.lowerOperation=>=

This is now returning articles that does NOT have the offTime property; also it returns articles that DO have the offTime date and are current.

Wednesday, 5 February 2014

Adobe CQ/AEM package install behaviour - filter.xml

Encountered a problem that whenever a package is deploy / installed, it will overwrite existing content and folder structure that was setup.

Using the filter.xml under META-INF/vault, we can configure it in a way that it keep existing content intact.

http://www.wemblog.com/2012/04/how-to-change-package-install-behavior.html

There are three Modes available:

  1. replace: Normal behavior. Existing content is replaced completly by the imported content, i.e. is overridden or deleted accordingly.
  2. merge: Existing content is not modified, i.e. only new content is added and none is deleted or modified
  3. update: Existing content is only updated but never deleted



Add it under META-INF/vault/filter.xml
<?xml version="1.0" encoding="UTF-8"?>

<workspaceFilter version="1.0">
    <filter root="/content" mode="update"/>
</workspaceFilter>


Advance package filtering include / exclude regular expression

http://aemfaq.blogspot.com.au/2013/04/cq5-package-filter-includeexclude.html

Example META-INF/vault/filter.xml
<?xml version="1.0" encoding="UTF-8"?>

<workspaceFilter version="1.0">
    <filter root="/content" mode="update">
        <include pattern="/content/foo/bar/*"/>
        </filter>
</workspaceFilter>



Tuesday, 14 January 2014

Java - re-using test classes across different projects | modules | packages

Reference:
http://blog.frankel.ch/re-use-your-test-classes-across-different-projects

In the POM.xml of the project|module that you have your testing code in src/test/java, include this plugin:
<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.2</version>
        <executions>
          <execution>
            <goals>
              <goal>test-jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

The test artifact is stored side-by-side with the main artifact once deployed in the repository. Note that the configured test-jar is bound to the install goal. E.g:
[your project|module name]/src/main/
[your project|module name]/src/test/


In the other project|module POM.xml, include this dependency:
<dependency>
  <groupId>com.rookiegeek.foobar</groupId>
  <artifactId>foo-bar</artifactId>
  <version>1.0.0</version>
  <type>test-jar</type>
  <scope>test</scope>
</dependency>

The type has to be test-jar instead of simply jar in order to Maven to pick the attached artifact and not the main one. Also, note although you could configure the dependency with a classifier instead of a type, the current documentation warns about possible bugs and favor the type configuration.