Weblogic path alias

The WAR artifact that I’m deploying to weblogic is a snapshot and is named with the version. In its normal deployment, it can be reached with domain/artifact-0.1.0-SNAPSHOT and thats not really how I want to have it named in source code making reference to it. So, I wanted to find a way to alias that path with a simpler path in the apache httpd.conf file. The following sample code shows a proper way to do this:

<Location /artifact>
 SetHandler weblogic-handler
 WebLogicCluster server:port
 PathTrim /artifact
 PathPrepend /artifact-0.1.0-SNAPSHOT
</Location>

This will redirect /artifact –> /artifact-0.1.0-SNAPSHOT

Annoying Android updates

Have you rooted and modified your Android phone? Are the vendor-pushed updates getting annoying? Follow this guide to silence those updates and be in control of your own upgrades:

Step 0: Be root.

$ su

Step 1: Mount the /system folder as read/write.

$ mount -o remount,rw /system

Step 2: Create an unwanted apps folder.

$ cd /system
$ mkdir app_hell

Step 3: Move the unwanted app (In this case, we’re moving the firmware upgrade app).

$ mv app/FWUpgrade.apk app_hell/. 
$ mv app/FWUpgrade.odex app_hell/.

Step 4: Remount the /system folder back to read-only.

$ mount -o remount,ro /system

Step 5: Drink a beer.

Headless install of JDK on MacOSX

Chef and terminal examples for headlessly installing JDK.

Chef:

case node["platform_family"]
when "mac_os_x"

	destfile = '/tmp/jdk-7u40-macosx-x64.dmg'
	execute "curl -k -O #{web/adddress/to/jdk}" do
	  cwd '/tmp'
	  not_if { ::File.exists? destfile }
	end		

	execute "attach dmg" do
	  cwd "/tmp"
	  command "hdiutil attach -noverify -nobrowse -mountpoint /tmp/jdk #{destfile}"
	end

	execute "install jdk" do
	  cwd "/tmp"
	  command "sudo installer -verbose -pkg jdk/JDK\\ 7\\ Update\\ 40.pkg -target /"
	end

	execute "detach dmg" do
	  cwd "/tmp"
	  command "hdiutil detach /tmp/jdk"
	end

	execute "rm -rf /tmp/jdk"

	execute "ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/ /Library/Java/Home"

	ENV["JAVA_HOME"] = "/Library/Java/Home"
end

Terminal:

$ cd /tmp
$ curl -k -O #{web/adddress/to/jdk}
$ hdiutil attach -noverify -nobrowse -mountpoint /tmp/jdk #{path/to/downloaded/file}
$ sudo installer -verbose -pkg jdk/JDK\ 7\ Update\ 40.pkg -target /
$ hdiutil detach /tmp/jdk
$ ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/ /Library/Java/Home

Bash test operators

A cheat sheet for bash test operators:

Math Operators Meaning
-eq equal to
-ne not equal to
-lt less than
-le less than or equal to
-gt greater than
-ge greater than or equal to
String Operators  
= equal to
!= not equal to
-n not null and exists
-z null and exists
File Operators  
-s not empty
-f is file and not a directory
-d is directory and not a file
-w is writeable
-r is read-only
-x is executable
Logical Operators  
! not
-a and
-o or

Urge to kill rising

Sometimes you just gotta kill something. Here’s a useful script for killing a process if it exists.

$ ps -ef  | grep [p]rocess | awk '{print $2}' | xargs -r kill

The square brackets will filter out the grep command from the process list.