Skip to content

Instantly share code, notes, and snippets.

View andrerigon's full-sized avatar

André Gonçalves andrerigon

View GitHub Profile
// Homework 1
// Color to Greyscale Conversion
//A common way to represent color images is known as RGBA - the color
//is specified by how much Red, Grean and Blue is in it.
//The 'A' stands for Alpha and is used for transparency, it will be
//ignored in this homework.
//Each channel Red, Blue, Green and Alpha is represented by one byte.
//Since we are using one byte for each color there are 256 different
#!/usr/bin/env ruby
n = ARGV[0].to_i
f = open("pph_#{n}_01.dat", "w") do |f|
f.write("#{n}\n")
(n).downto(1) { |i| f.write("1 ") }
f.write("\n#{n}\n")
(n).downto(1) { |i| f.write("1 ") }
f.write("\n1\n")
24 0.000534
449 0.000847
619 0.001006
801 0.001160
902 0.001320
1013 0.001270
1360 0.001649
1523 0.002787
1719 0.002181
1817 0.002425
@andrerigon
andrerigon / ab.rb
Created September 12, 2012 13:49
ab fixed formula for homebrew in lion
require 'formula'
class Ab < Formula
homepage 'http://httpd.apache.org/docs/trunk/programs/ab.html'
url 'http://www.apache.org/dist/httpd/httpd-2.4.3.tar.bz2'
sha1 '0ef1281bb758add937efe61c345287be2f27f662'
def install
# Mountain Lion requires this to be set, as otherwise libtool complains
# about being "unable to infer tagged configuration"
@andrerigon
andrerigon / InterfaceParanamerNamesProvider.java
Created August 16, 2011 16:36
InterfaceParanamerNamesProvider - if the method is from an interface, tries to find an implementation.
@Component
@ApplicationScoped
public class InterfaceParanamerNamesProvider extends ParanamerNameProvider {
// @Autowired
// Container container;
@Override
public String[] parameterNamesFor(AccessibleObject aMethod) {
Method method = (Method) aMethod;
@andrerigon
andrerigon / InterfaceBasedPathAnnotationRoutesParser.java
Created August 16, 2011 14:03
PathAnnotationRoutesParser that uses an interface if the controller has one
import java.util.List;
import br.com.caelum.vraptor.http.route.PathAnnotationRoutesParser;
import br.com.caelum.vraptor.http.route.Route;
import br.com.caelum.vraptor.http.route.Router;
import br.com.caelum.vraptor.ioc.ApplicationScoped;
import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.resource.ResourceClass;
@Component
@andrerigon
andrerigon / maven_debug_opts.sh
Created November 26, 2010 19:28
maven plugin debug
export MAVEN_OPTS = "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y"
@andrerigon
andrerigon / DetachedCriteriaSample.java
Created November 23, 2010 01:51
hibernate subquery detached criteria sample
public List<Product2> all() {
DetachedCriteria subquery = DetachedCriteria.forClass(Product1.class)
.add(Restrictions.eq("name", "bola"))
.setProjection(Property.forName("codprod1"));
return session().createCriteria(Product2.class)
.add(Property.forName("codprod1").in(subquery)).list();
}