Skip to content

Instantly share code, notes, and snippets.

View fabriciofx's full-sized avatar
🎯
Focusing

Fabricio Cabral fabriciofx

🎯
Focusing
  • Brazil
View GitHub Profile
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface PreventExternalAccess {
}
@Resource
public class CategoriaController {
private final Result result;
private final CategoriaService service;
private final Validator validator;
public CategoriaController(CategoriaService service, Result result,
Validator validator) {
this.service = service;
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000"
redirectPort="8443"
compression="on"
compressionMinSize="1024"
compressableMimeType="text/css,application/javascript" />
@ManagedBean
public class UserBean {
private String name;
private List<User> users = new ArrayList<User>();
public String listAll() {
UserDao dao = new UserDao();
this.users = dao.findByName(name);
return "list";
public class MyTest {
@Rule
public MethodRule screenshot = new ScreenshotOnFailureRule();
@Test
public void myTest() { ... }
...
}
@Entity
public class Bem implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
$.validator.addMethod("lessOrEqualsThan", function(value, element, param) {
var parsedValue = value.replace(/\./g, "").replace(",", ".");
return this.optional(element) || (parseFloat(parsedValue) <= param);
}, "Valor deve ser menor ou igual a {0}.");
$.validator.addMethod("inRange", function(value, element, param) {
var parsedValue = value.replace(/\./g, "").replace(",", ".");
var amount = parseFloat(parsedValue);
return this.optional(element) || (amount >= param[0] && amount <= param[1]);
}, "Valor deve estar entre {0} e {1}.");
sudo mysqldump -u root old_schema | mysql -u root new_schema
find -name "*.jsp" | xargs sed -i "s:\\]\[:,:g" && find -name "*.jsp" | xargs sed -i "s:\(linkTo\[[a-zA-Z0-9]*\]\.[a-zA-Z0-9]*\)\[\(.*\)\]:\1(\2):"
public class Validate {
public static boolean not(boolean expression){
return !expression;
}
public static boolean in(String value, String[] options){
return StringUtil.in(value, options);
}