Skip to content

Instantly share code, notes, and snippets.

@fiorenzino
Created June 17, 2013 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fiorenzino/5800641 to your computer and use it in GitHub Desktop.
Save fiorenzino/5800641 to your computer and use it in GitHub Desktop.

Raw

Raw

Example 1. Task list from the imported Ant project
$ gradle tasks
:tasks

dependencies - Displays the dependencies of root project 'ant-import-to-gradle'.
help - Displays a help message
projects - Displays the sub-projects of root project 'ant-import-to-gradle'.
properties - Displays the properties of root project 'ant-import-to-gradle'.
tasks - Displays the tasks in root project 'ant-import-to-gradle'.

Ruby

 ---------------------------------------------------------------------
 #
 # Useful Ruby base class extensions.
 #
class Array
# Execute a block passing it corresponding items in
# +self+ and +other_array+.
# If self has less items than other_array it is repeated.
def cycle(other_array)  # :yields: item, other_item
  other_array.each_with_index do |item, index|
    yield(self[index % self.length], item)
  end
end
end
if $0 == __FILE__                                 # (1)
  # Array#cycle test
  # true => 0
  # false => 1
  # true => 2
  # false => 3
  # true => 4
  puts 'Array#cycle test'                         # (2)
  [true, false].cycle([0, 1, 2, 3, 4]) do |a, b|
    puts "#{a.inspect} => #{b.inspect}"
  end
end
---------------------------------------------------------------------
<1> First callout.
<2> Second callout.

Java Code Syntax Highlighting

Java Highlighted

Example 2. Gradle build script defining variables
def helloName = "Fird Birfle"
int personAge = 43

task hello << {
    println "Hello ${helloName}. I believe you are ${personAge} years of age."
}

Java Code Raw

Java Raw

Example 3. Gradle build script defining variables
def helloName = "Fird Birfle"
int personAge = 43

task hello << {
    println "Hello ${helloName}. I believe you are ${personAge} years of age."
}

XML

XML Highlighted

Example 4. Ant build.xml zipping the source files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment