More necessary knowledge for every web developer

Just a few links to articles I do not want to lose:

How to run a Windows executable with different environment variables

After an update to the Google Drive desktop software, it refused to download new files created online or on another device but changes to existing files where reflected correctly.

I solved it by starting the process with a different “TEMP” environment variable:

C:\Windows\System32\cmd.exe /c 
    "SET TEMP=C:\Temp && 
     START /D ^"C:\Program Files (x86)\Google\Drive\^" googledrivesync.exe"

Read more »

What every web developer must know about URL encoding

Just a link to a blog post I should never lose: What every web developer must know about URL encoding.

Abstract:

This article describes common misconceptions about Uniform Resource Locator (URL) encoding, then attempts to clarify URL encoding for HTTP, before presenting frequent problems and their solutions. While this article is not specific to any programming language, we illustrate the problems in Java) and finish by explaining how to fix URL encoding problems in Java, and in a web application at several levels.

Necessary knowledge for every web developer!

Branch by abstraction and trunk based development

Recently I have been trying to figure out the best way to handle parallel development of bug fixes and new functionalities.

As I am using GIT (in front of an SVN repo) I thought about feature, release and hotfix branches as described in the excellent blog post A successful Git branching model by Vincent Driessen. Best used with the gitflow GIT extensions.

The model explains that “feature branches typically exist in developer repos only, not in origin” but this is not feasible for our team. Some feature branches take long to be developed (> 1 week, often > 1 month). You should not keep more than a couple of days work on your developer machine without pushing to the repository. (YMMV of course.)

Peer-reviewing a whole feature branch when development is finished (and merged and pushed back to the repository?) is just too hard. We like to review commit-by-commit — changes are much easier to follow and understand that way. If everyone on the team would use GIT we could push/pull changes to each other but this creates a lot of branch management overhead especially if you have many parallel feature branches. (At one point we had 9 feature branches and 6 release branches, at the same time.)
Read more »

One hour GC pause

We were trying to tune the Sun JVM Garbage Collector of our WebLogic Server v. 10.3.2 when the server stopped for over one hour. It was lunch time so we did not kill the process. After 4012 seconds it came back. For your information, the server was a development instance with a 512 MB JVM on Solaris 9.

Here is the log message (wrapped for readability):

2012-01-10T12:48:31.227+0100: 
    10361.371: [GC[YG occupancy: 23095 K (29504 K)]
    10361.371: [Rescan (parallel) , 4012.3452758 secs]
    14373.717: [weak refs processing, 0.0006401 secs]
    14373.717: [class unloading, 0.0815919 secs]
    14373.799: [scrub symbol & string tables, 0.1392282 secs] 
    [1 CMS-remark: 416411K(491520K)] 439506K(521024K), 4012.6147003 secs] 
    [Times: user=3959.56 sys=5.79, real=4012.61 secs] 

Read more »

How to prevent JSP recompilation in WebLogic Server

My previous post explains how to precompile JSPs with the WebLogic wlappc Ant task. This is a follow-up explaining how to prevent WebLogic Server to recompile the JSPs completely.

Add the following snippet to the weblogic.xml of your WAR.

<jsp-descriptor>
    <page-check-seconds>-1</page-check-seconds>
    <precompile>false</precompile>
</jsp-descriptor>

Add the following snippet to the web.xml of your WAR.

<servlet>
    <servlet-name>JSPClassServlet</servlet-name>
    <servlet-class>weblogic.servlet.JSPClassServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>JSPClassServlet</servlet-name>
    <url-pattern>*.jsp</url-pattern>
</servlet-mapping>

Read more »

How to precompile JSPs with the WebLogic wlappc Ant task

The following Ant snippet allows you to precompile your JSPs (and more) for WebLogic Server.

<!-- Define some properties -->
<property name="weblogic.server.dir" value="C:/Oracle/Middleware"/>
<property name="weblogic.server.lib.dir" value="${weblogic.server.dir}/wlserver_10.3/server/lib"/>
<property name="pathTo.weblogic.jar" value="${weblogic.server.lib.dir}/weblogic.jar"/>
<property name="war.src.dir" value="${basedir}/build/war"/>
<property name="war.dist.dir" value="${basedir}/dist"/>

<!-- Add the WebLogic appc task definition to the current project -->
<taskdef name="wlappc" classname="weblogic.ant.taskdefs.j2ee.Appc" classpath="${pathTo.weblogic.jar}"/>

<!-- Set up the classpath for the WebLogic appc task -->
<path id="wlappc.classpath">
    ...
</path>

<!-- Compile the source of your WAR file with weblogic.appc -->
<target name="wlCompileWarSrc">
    <wlappc source="${war.src.dir}" classpathref="wlappc.classpath" keepgenerated="true"
            debug="true" linenumbers="true" verbose="true" verbosejavac="true"/>
</target>

<!-- Make the project WAR -->
<target name="war" depends="wlCompileWarSrc">
    ...
</target>

Read more »

How to show which commits Git-SVN will push or merge

My previous post explains how to show which commits Git will push or merge. This is a follow-up explaining how to achieve the same with Git-SVN.

These are the aliases you need in your Git configuration file (e.g. C:cygwinhome<user>.gitconfig or <project>/.git/config). The explanation is below.

[alias]
    # -M                 Detect and report renames for each commit.
    # --name-status      Show only names and status of changed files.
    # --abbrev-commit    Instead of showing the full 40-byte hexadecimal commit object name, show only a partial prefix.
    l = log -M --name-status --abbrev-commit

    # --oneline          This is a shorthand for &amp;quot;--pretty=oneline --abbrev-commit&amp;quot; used together.
    l1 = log --oneline

    # log commits-to-push
    lctp  = &amp;quot;!REMOTE_BRANCH=$(git svn info --url | gawk -F'/' '{print $NF}'); 
            COMMAND=&amp;quot;git l remotes/$REMOTE_BRANCH..HEAD&amp;quot;; 
            echo $COMMAND; 
            $COMMAND&amp;quot;
    lctp1 = &amp;quot;!REMOTE_BRANCH=$(git svn info --url | gawk -F'/' '{print $NF}'); 
            COMMAND=&amp;quot;git l1 remotes/$REMOTE_BRANCH..HEAD&amp;quot;; 
            echo $COMMAND; 
            $COMMAND&amp;quot;

    # log commits-to-merge
    # do not forget to execute &amp;quot;git svn fetch&amp;quot; first
    lctm  = &amp;quot;!REMOTE_BRANCH=$(git svn info --url | gawk -F'/' '{print $NF}'); 
            COMMAND=&amp;quot;git l HEAD..remotes/$REMOTE_BRANCH&amp;quot;; 
            echo $COMMAND; 
            $COMMAND&amp;quot;
    lctm1 = &amp;quot;!REMOTE_BRANCH=$(git svn info --url | gawk -F'/' '{print $NF}'); 
            COMMAND=&amp;quot;git l1 HEAD..remotes/$REMOTE_BRANCH&amp;quot;; 
            echo $COMMAND; 
            $COMMAND&amp;quot;

Read more »

How to show which commits Git will push or merge

To show which commits Git will push or merge, these are the aliases you need in your Git configuration file (e.g. C:\cygwin\home\<user>\.gitconfig or <project>/.git/config). The explanation is below.

[alias]
    # -M                 Detect and report renames for each commit.
    # --name-status      Show only names and status of changed files.
    # --abbrev-commit    Instead of showing the full 40-byte hexadecimal commit object name, show only a partial prefix.
    l = log -M --name-status --abbrev-commit

    # --oneline          This is a shorthand for "--pretty=oneline --abbrev-commit" used together.
    l1 = log --oneline

    # log commits-to-push
    lctp  = "!LOCAL_BRANCH=$(git branch | grep ^* | gawk -F' ' '{print $NF}'); \
            REMOTE_SERVER=$(git config --get branch.$LOCAL_BRANCH.remote); \
            REMOTE_BRANCH=$(git config --get branch.$LOCAL_BRANCH.merge | gawk -F'/' '{print $NF}'); \
            COMMAND=\"git l $REMOTE_SERVER/$REMOTE_BRANCH..HEAD\"; \
            echo $COMMAND; \
            $COMMAND"
    lctp1 = "!LOCAL_BRANCH=$(git branch | grep ^* | gawk -F' ' '{print $NF}'); \
            REMOTE_SERVER=$(git config --get branch.$LOCAL_BRANCH.remote); \
            REMOTE_BRANCH=$(git config --get branch.$LOCAL_BRANCH.merge | gawk -F'/' '{print $NF}'); \
            COMMAND=\"git l1 $REMOTE_SERVER/$REMOTE_BRANCH..HEAD\"; \
            echo $COMMAND; \
            $COMMAND"

    # log commits-to-merge
    # do not forget to execute "git fetch" first
    lctm  = "!LOCAL_BRANCH=$(git branch | grep ^* | gawk -F' ' '{print $NF}'); \
            REMOTE_SERVER=$(git config --get branch.$LOCAL_BRANCH.remote); \
            REMOTE_BRANCH=$(git config --get branch.$LOCAL_BRANCH.merge | gawk -F'/' '{print $NF}'); \
            COMMAND=\"git l HEAD..$REMOTE_SERVER/$REMOTE_BRANCH\"; \
            echo $COMMAND; \
            $COMMAND"
    lctm1 = "!LOCAL_BRANCH=$(git branch | grep ^* | gawk -F' ' '{print $NF}'); \
            REMOTE_SERVER=$(git config --get branch.$LOCAL_BRANCH.remote); \
            REMOTE_BRANCH=$(git config --get branch.$LOCAL_BRANCH.merge | gawk -F'/' '{print $NF}'); \
            COMMAND=\"git l1 HEAD..$REMOTE_SERVER/$REMOTE_BRANCH\"; \
            echo $COMMAND; \
            $COMMAND"

Read more »

How to configure Git on Windows (under Cygwin) to use Beyond Compare 3

Let’s get to the point.
To configure Git on Windows (under Cygwin) to use Beyond Compare 3, you should have the following in your .gitconfig file (e.g. C:\cygwin\home\<user>\.gitconfig):

[[diff]]
    tool = mybc3
[difftool "mybc3"]
    cmd = \"c:/program files/beyond compare 3/BComp.com\" \"$(cygpath -w \"$LOCAL\")\" \"$(cygpath -w \"$REMOTE\")\" /lefttitle=\"$(cygpath -w \"$LOCAL\")\" /righttitle=\"$(cygpath -w \"$REMOTE\")\" /leftreadonly /rightreadonly
[difftool]
    prompt = false
[merge]
    tool = mybc3
[mergetool "mybc3"]
    cmd = \"c:/program files/beyond compare 3/BComp.com\" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\" /lefttitle=\"$LOCAL\" /righttitle=\"$REMOTE\" /centertitle=\"$BASE\" /outputtitle=\"$MERGED\" /leftreadonly /rightreadonly /centerreadonly
    keepBackup = false
    trustExitCode = true
[mergetool]
    prompt = false

Read more »