Skip to content

Instantly share code, notes, and snippets.

View guilhermesilveira's full-sized avatar

Guilherme Silveira guilhermesilveira

View GitHub Profile
public class MyWeld {
private static WeldContainer weldContainer = new Weld().initialize();
public static void main(String[] args) {
System.out.println(get(Router.class).allRoutes().size());
get(Router.class).allRoutes().stream().map(Route::getOriginalUri).forEach(System.out::println);
}
private static <T> T get(Class<T> type) {
wget http://dl.bintray.com/caelum/VRaptor4/vraptor-blank-project--4.1.0-RC2.zip
unzip vraptor-blank-project--4.1.0-RC2.zip
cd vraptor-blank-project
mvn tomcat:run
Tomcat 6 escolhido:
> INFO: Starting Servlet Engine: Apache Tomcat/6.0.29
curl -v http://localhost:8080
* Adding handle: conn: 0x7fdef4003000
@guilhermesilveira
guilhermesilveira / ClientsController.java
Created October 21, 2014 19:29
Data Binding MVC example
package br.com.caelum.mvc;
public class ClientsController {
// reflection based conversion is NOT safe
public void save1(Client client) {
}
// primitives are safe
class ClientCss {
public static String client_portfolio = "portfolio";
public static String client_card = "card";
public static String client_photo = "photo";
}
- double
- em horas
newInterval = 48
initialStepSmall = 1minute
initialStepBig = 10minutes
easyBonus = 1.3
function soma(a,b) {
return a + b;
}
function maior(a,b) {
if(a > b) return a;
return b;
}
function somaPositivos(a) {
#define TAMANHO_MAXIMO_DO_SEGREDO 4
#define REPETICOES_ESTADO_FINAL 3
#define TEMPO_LUZ 1000
#define TEMPO_PAUSA 500
#define ledVerde 2
#define ledAmarelo 3
#define ledVermelho 4
#define ledBranco 5
resource = Restfulie.at('http://localhost:3000/items').as("application/xml").post!(:item => { :name => "Robin costume", :price => 25.0})
resource = Restfulie.at('http://localhost:3000/items').as("application/json").post!(:item => { :name => "Robin costume", :price => 25.0})
resource = Restfulie.at('http://localhost:3000/items').as("application/atom+xml").post!(:item => { :name => "Robin costume", :price => 25.0})
# already follows 201
class ItemsController < ApplicationController
include Restfulie::Server::ActionController::Base
respond_to :xml, :json
def index
@items = Item.all
respond_with @items
end
collection(@items) do |collection|
collection.link "basket", baskets_url
collection.members do |member, item|
partial "show", binding
end
end