This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Groovy also has a Time Category class which gives you DSL style syntax for manipulating dates. Here is an example: | |
import org.codehaus.groovy.runtime.TimeCategory | |
now = new Date() | |
println now | |
use(TimeCategory) { | |
footballPractice = now + 1.week - 4.days + 2.hours - 3.seconds | |
} | |
println footballPractice | |
which will produce output like this: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*- | |
%% ex: ts=4 sw=4 et | |
[ | |
{default_bucket_props, [{n_val,1}, | |
{allow_mult,false}, | |
{last_write_wins,false}, | |
{precommit, []}, | |
{postcommit, []}, | |
{chash_keyfun, {riak_core_util, chash_std_keyfun}}, | |
{linkfun, {modfun, riak_kv_wm_link_walker, mapreduce_linkfun}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: src/main/java/com/basho/riak/pbc/RiakObject.java | |
=================================================================== | |
--- src/main/java/com/basho/riak/pbc/RiakObject.java (revision 84) | |
+++ src/main/java/com/basho/riak/pbc/RiakObject.java (revision 125) | |
@@ -244,4 +244,8 @@ | |
return d; | |
} | |
+ public String getContentType() { | |
+ return contentType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.camel.impl.DefaultCamelContext; | |
import org.apache.camel.language.groovy.GroovyRouteBuilder; | |
import org.apache.camel.* | |
@Grab(group='org.slf4j', module='slf4j-api', version='1.6.1') | |
@Grab(group='org.slf4j', module='slf4j-log4j12', version='1.6.1') | |
@Grab(group='org.apache.camel', module='camel-groovy', version='2.8.0') | |
@Grab(group='org.apache.camel', module='camel-core', version='2.8.0') | |
@Grab(group='org.apache.camel', module='camel-jetty', version='2.8.0') | |
class SampleRoute extends GroovyRouteBuilder { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
START=$(date +%s.%N) | |
for i in {1..100}; | |
do | |
curl http://localhosT:3000/rest -d '<request>'>/dev/null 2>&1 | |
done; | |
END=$(date +%s.%N) | |
DIFF=$(echo "$END - $START" | bc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gfrison | |
import groovy.json.* | |
import static org.apache.commons.lang3.StringUtils.* | |
/** | |
* @author Giancarlo Frison <[email protected]> | |
* | |
* rate the affinity between 2 different web sites | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//just to avoid 'string ...' with spaces | |
//trim a string http://stackoverflow.com/a/498995 | |
String.prototype.trim=function(){return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');}; | |
//improvement of this: http://blog.mastykarz.nl/measuring-the-length-of-a-string-in-pixels-using-javascript/ | |
var visualLength = function(str){ | |
var ruler = document.createElement('span'); | |
ruler.style.visibility = 'hidden'; | |
ruler.style['white-space'] = 'nowrap'; | |
document.body.appendChild(ruler); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grep ‘text-2-search’ * | cut -f1 -d':' | xargs tar -zcvf pack.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vertx = require("vertx.js") | |
var console = require('vertx/console'); | |
console.log('module ' + JSON.stringify(module)); | |
var dust; | |
var x = function(){ | |
var module = undefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.thoughtworks.xstream.core.util.PrioritizedList | |
import groovy.transform.Field | |
import java.text.DecimalFormat | |
/** | |
* Dodgsons Duoblets | |
* | |
* User: gfrison | |
* http://programmingpraxis.com/2009/03/20/dodgsons-doublets/ |
OlderNewer