Skip to content

Instantly share code, notes, and snippets.

View melix's full-sized avatar

Cédric Champeau melix

View GitHub Profile
@melix
melix / SpanOrPb.java
Created June 15, 2011 09:46
Throws a parse error when query gets executed
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.action.search.SearchRequestBuilder;
import org.elasticsearch.index.query.xcontent.SpanOrQueryBuilder;
import org.elasticsearch.index.query.xcontent.SpanTermQueryBuilder;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
@melix
melix / gist:1333594
Created November 2, 2011 13:17
Error in presentation
2011-11-02 14:15:57,622 [main] INFO griffon.swing.SwingApplication - Initializing all startup groups: [DeckLauncher]
Corrupt JPEG data: bad Huffman code
2011-11-02 14:16:17,264 [pool-2-thread-3] ERROR org.codehaus.griffon.runtime.builder.UberBuilder - An error occurred while building Page15Slide@2933092e
groovy.lang.MissingPropertyException: No such property: chart for class: griffonevo.SecondChart3D
Possible solutions: class
at griffonevo.SecondChart3D.initChart(SecondChart3D.groovy:36)
at griffonevo.SecondChart3D$initChart.callCurrent(Unknown Source)
at griffonevo.SecondChart3D.mvcGroupInit(SecondChart3D.groovy:16)
at griffonevo.SecondChart3D$mvcGroupInit.call(Unknown Source)
at griffon.core.GriffonMvcArtifact$mvcGroupInit.call(Unknown Source)
@melix
melix / recherche.groovy
Created December 13, 2011 15:28
Recherche force brute en groovy
@Grab('org.codehaus.gpars:gpars:0.12')
@Grab('org.jasypt:jasypt:1.8')
import org.jasypt.util.text.BasicTextEncryptor
import groovyx.gpars.GParsPool
println 'Dépendances téléchargées.'
class ForceBrute {
private final static String texte = "5oi/MCVWOrk2V8bI2LY4XM4gKf/hqRnz6/d0HftJYadMv7xkIjUsTfvXyyf0kJ/D1Or0QMicOUf7YIAkAMWkbNJpLA5cgOHZvGZVC1LBGdpe0n3zY5VfyYjUIFu/0VNyLVMOAu4BaC3ncdPkh5Q0r+IQeTV+IqOOBlsozTfxeLYBJhxIUdSaXIVubo7RSPOn1Y0aLrTEZhlPkJFJhQohhOr5d0/zqre7HnFdc/9vSC3qda6VKwxd+yAhl762kOGReE4YbeMX/1wg175ruUaT4tgVYaOLXIRg0fqZYIwu37KUrOvtUD+inZSYwMpUrNSeV9Wshwoi6kBXkriEoc2Qg58b6WVfNTzGMFsRp/D4TGMx04hGg2WTT4lRPebqGl5cPm6qSeb7WET3xbJ4LUCvOgX0cDr22inxlGUgkbF7m8ApZw2kOverBgnhW+dE3amE+bP1Ac1ky4sSY0Sjeec2n4QI6hX9mwl7GBc9Ep8uF7t+XdZFmuml4/bFgxtDOpi8zQ6NYXe2/UT5S6i/hPPHHRa6OGL2ZAswBtAkcsYiw564hshKvzVOMtP05Zu19C1zY+84kmpsGbxxknSI61owCNOvF1tJitww4EmkLsIhgveV+RcmTQOiwONJET7Q9qK4RFpFuz+hu1Kel0QsMPZMlvhSsSTj+lmLHzG9nC5s4RcvLR1JeL27MvcfO0CxZx9XSYazu+LqVK2qlv+NXftT9JFx19hVIvAI/T4oM9xf3wYrLozs1GDRrPju2yVXZb91vn4TdWWIoX
@melix
melix / StaticTypesCallSiteWriter.java
Created December 15, 2011 18:06
Static types NumberNumberXXX
/*
* Copyright 2003-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Calculation of Pi using quadrature realized with a basic sequential algorithm and enforcing primitive
* types throughout.
*
* Copyright © 2008–2011 Russel Winder
*/
// This is Groovy and so extraordinarily slow compared to Java. Use primitive types though so as to avoid
// really bad performance due to use of Integer and BigDecimal. Hence the careful markup of the literals as
// well as the variables.
@melix
melix / setmethodtarget.diff
Created December 29, 2011 10:04
setMethodTarget in Verifier
diff --git a/src/main/org/codehaus/groovy/classgen/Verifier.java b/src/main/org/codehaus/groovy/classgen/Verifier.java
index a4ed9fa..3c804ef 100644
--- a/src/main/org/codehaus/groovy/classgen/Verifier.java
+++ b/src/main/org/codehaus/groovy/classgen/Verifier.java
@@ -666,6 +666,7 @@ public class Verifier implements GroovyClassVisitor, Opcodes {
addDefaultParameters(methods, new DefaultArgsAction() {
public void call(ArgumentListExpression arguments, Parameter[] newParams, MethodNode method) {
MethodCallExpression expression = new MethodCallExpression(VariableExpression.THIS_EXPRESSION, method.getName(), arguments);
+ expression.setMethodTarget(method);
expression.setImplicitThis(true);
@melix
melix / ldc.patch
Created December 30, 2011 13:23
Make use of LDC for class literals when possible
Index: groovy-git/src/main/org/codehaus/groovy/classgen/Verifier.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- groovy-git/src/main/org/codehaus/groovy/classgen/Verifier.java (date 1325233165000)
+++ groovy-git/src/main/org/codehaus/groovy/classgen/Verifier.java (revision )
@@ -210,7 +210,7 @@
node.addConstructor(constructor);
}
@melix
melix / DirectMethodCallWithVargsTest.groovy
Created January 11, 2012 17:06
Direct method calls with vargs throws AIOBE
package groovy.bugs
import org.codehaus.groovy.ast.ClassCodeVisitorSupport
import org.codehaus.groovy.control.SourceUnit
import org.codehaus.groovy.ast.expr.MethodCallExpression
import org.codehaus.groovy.ast.MethodNode
import org.codehaus.groovy.control.CompilerConfiguration
import org.codehaus.groovy.control.customizers.CompilationCustomizer
import org.codehaus.groovy.control.CompilePhase
import org.codehaus.groovy.classgen.GeneratorContext
/*
* Copyright 2003-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@melix
melix / proxygen.groovy
Created February 1, 2012 12:13
Proxy generation benchmark
interface Foo {}
abstract class AbstractFoo {}
abstract class SingleAbstract { abstract int foo() }
def tests = [
'mapAsAbstractClass': { [:] as AbstractFoo },
'mapWithOneMethodAsAbstractClass': { ['foo': { 1 } ] as SingleAbstract }
]
tests.each { name, test ->