Skip to content

Instantly share code, notes, and snippets.

View rynmrtn's full-sized avatar

Ryan Morton rynmrtn

View GitHub Profile
@rynmrtn
rynmrtn / gist:168084
Created August 14, 2009 20:26
Backup Subversion Repository
$ svnadmin dump /repo/dir > repo.dump
$ rsync -avz -e ssh username@remote.server:/remote/dir /local/dir
# Create an associative array of options/values
@options = {"Select Something" => 0, "Cat" => 1,
"Dog" => 2}
@value = 1
#
# Check if files/directories exist
if [ -f file ]; then
echo "file exists"
fi
if [ -d dir ]; then
echo "dir exists"
fi
@rynmrtn
rynmrtn / traits.scala
Created December 11, 2009 02:42
Scala Traits
/*
Playing with Scala Traits, a nice way to add (mixin) functionality
to classes using the decorator pattern.
With traits, the evaluation occurs left to right. Traits can be
applied to class/trait definitions in addition to objects, as
demonstrated by the class ContinuousIntegration
*/
class Test {
def test() : String = "Testing... "
@rynmrtn
rynmrtn / collections.scala
Created December 12, 2009 19:49
Notes on Scala Collections
/*
Notes on Collections
By default, Scala uses immutable collections. However, there are mutable
versions available (in the scala.collection.mutable package). The most common
collections are List, Set, and Map.
*/
// Declaring a set
val urls = Set("google.com", "yahoo.com", "nytimes.com")

Enable Remote Debugging on a Java Server

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5001

The best documentation on this is available from InformIT. This site details the following parameters:

  • -Xdebug : Enables the application to be debugged.
  • -Xnoagent : Disables the sun.tools.debug agent so that the JPDA debugger can properly attach its own agent.
  • -Djava.compiler=NONE : Disables the JIT (Just-In-Time) compiler.
  • -Xrunjdwp : Loads the reference implementation of the Java Debug Wire Protocol, which enables remote debugging.

Immutable vs. Mutable Objects

Advantages of Immutable

  • There is no way for multiple threads to concurrently mutate or access an immutable value as no thread can change an immutable object.
  • When passing a value into foreign code, one can be assured that an immutable value will not change.
  • There are fewer concerns - immutable objects cannot have complex states that change over time.

Disadvantages of Immutable

  • When an object is quite large, it is inefficient to update the full object graph. In some cases, it is best to do an in-place modification.
@rynmrtn
rynmrtn / faces.mdown
Created January 4, 2010 18:03
Notes on Seam Framework

JSF and RichFaces Notes

Validators:

<!-- Combination of rich:beanValidator and a4j:support. This will bind to the hibernate validators for the model and
     validate when the field is no longer in focus (onblur). The event could be any supported event.
-->
<rich:ajaxValidator event="onblur" />
@rynmrtn
rynmrtn / insert.groovy
Created January 22, 2010 21:07
Groovy script to generate insert statements from a CSV file
/**
This groovy script will take a CSV file that represents the data
in a database. The first row should be the name of the columns and
all other rows should represent the data you wish to insert.
*/
// Setup basic information
tableName = "TABLE_NAME"
fileName = "C:\\file\\path"