Skip to content

Instantly share code, notes, and snippets.

@gfrison
gfrison / rxnetty multi part problem
Created August 26, 2015 08:39
rxnetty multi part problem
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Random;
import io.netty.handler.logging.LogLevel;
import io.reactivex.netty.protocol.http.client.HttpClient;
public class ConcatUpload
{
@gfrison
gfrison / gist:a8d31c761040203b4014
Last active August 29, 2015 14:16
embedded (without spring boot) spring cloud netflix-hystrix example
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes = {HistrixIT.Config.class})
public class HistrixIT
{
@Autowired
private RemoteService service;
private static Function<String, String> function = mock(Function.class);

Keybase proof

I hereby claim:

  • I am gfrison on github.
  • I am gfrison (https://keybase.io/gfrison) on keybase.
  • I have a public key whose fingerprint is 83D5 27E0 3F34 C133 F4B3 11D4 1145 0972 D3CC EDA9

To claim this, I am signing this object:

@gfrison
gfrison / doublets.groovy
Created February 17, 2014 12:04
Dodgsons doublets in Groovy. The rules of the Puzzle are simple enough. Two words are proposed, of the same length; and the Puzzle consists in linking these together by interposing other words, each of which shall differ from the next word in one letter only. That is to say, one letter may be changed in one of the given words, then one letter in…
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/
@gfrison
gfrison / main.js
Created January 16, 2014 22:37 — forked from carchrae/main.js
var vertx = require("vertx.js")
var console = require('vertx/console');
console.log('module ' + JSON.stringify(module));
var dust;
var x = function(){
var module = undefined;
@gfrison
gfrison / gist:2701839
Created May 15, 2012 13:36
pack files containing specific text
grep ‘text-2-search’ * | cut -f1 -d':' | xargs tar -zcvf pack.tar.gz
@gfrison
gfrison / gist:2653014
Created May 10, 2012 13:32
truncating a string in javascript according to the REAL length of chars and tooltip the full-size string in the element
//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);
@gfrison
gfrison / Affinity.groovy
Created February 20, 2012 16:34
Rate affinity score between 2 web sites
package com.gfrison
import groovy.json.*
import static org.apache.commons.lang3.StringUtils.*
/**
* @author Giancarlo Frison <giancarlo@gfrison.com>
*
* rate the affinity between 2 different web sites
*
@gfrison
gfrison / gist:1348082
Last active September 27, 2015 23:18
script bash for performance testing on RESTful services. It measures quickly how long does it take accomplish http requests
#!/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)
@gfrison
gfrison / gist:1347781
Created November 8, 2011 13:53
groovy camel builder script
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 {