Skipping locally updated files with Git

If you have a local file that you’ve updated locally (like a properties file) but you want to avoid committing the changes when you next commit, use this command:

git update-index --skip-worktree path/to/filename

If you need to add it back to the list of tracked files, then use this:

git update-index –no-skip-worktree path/to/filename

MongoDB usage notes

MongoDB Shell commands:

#list dbs on server:
show dbs

#show collections in current db
show collections

#switch to db
use databasename;

#find everything and print as json
db.collectionname.find().forEach(printjson);

#’like’ query:
db.collectionname.find(fieldname:/pattern/).forEach(printjson);

#count results:
db.collectionname.find().count();

#return only requested properties (similar to ‘select x, y, z from table a’)
db.collectionname.find({}, {fieldname1:1, fieldname2:1}).forEach(printjson)

#select min x by sorting in asc order and picking first result
db.collectionname.find().sort({x: 1}).limit(1).forEach(printjson)

#select max x by sorting in desc order and picking first result
db.collectionname.find().sort({x: -1}).limit(1).forEach(printjson)

#add an index for property x
db.collectionname.ensureIndex({x: 1})

Stats webapp: http://localhost:28017/

DeploymentScanner timeouts on OpenShift JBoss AS7

I haven’t seen this error often on the hosted OpenShift service (only occasionally when there’d been a system update and your app doesn’t redeploy correctly once restarted), but running OpenShift Origin locally I was seeing this consistently trying to deploy a new application:

2012/07/25 15:00:24,158 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015052: Did not receive a response to the deployment operation within the allowed timeout period [60 seconds]. Check the server configuration file and the server logs to find more about the status of the deployment.
2012/07/25 15:00:24,160 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "ROOT.war" was rolled back with failure message Operation cancelled

To increase the deployment scanner’s timeout setting, edit your project’s .openshift/config/standalone.xml, and find the deployment-scanner element:

<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
            <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" />
        </subsystem>

…and then add this attribute to <deployment-scanner> :

deployment-timeout="1200"

The XSD schema for this element says the default value is 600 second, but the error above says it’s timing out after 60 seconds. Assuming the default value is 600, I doubled it, and this fixed my timeout issues.

Controlling Services on Fedora

Fedora uses the servicectl utility to enable/disable and control services.

To use:

sudo servicectl status servicename
sudo servicectl enable/disable servicename
sudo servicectl start|stop servicename