Skip to content

Instantly share code, notes, and snippets.

View krisskross's full-sized avatar

Christofer Sjögren krisskross

View GitHub Profile
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
@Config @NotNull @Size(min=1, max=5)
List<Person> persons;
@Config @NotNull @Size(min=8, max=25)
@Config(desc = "An individual (or application program) identity")
public class User {
@Id(desc = "username")
private String username;
@Config(desc = "password")
private String password;
@Config(desc = "Roles assigned to this user")
private Set<Role> roles = new HashSet<Role>();
BeanId deployerRoleId = BeanId.create("deployer", Role.class.getName());
Bean deployer = Bean.create(deployerRoleId);
BeanId assemblerRoleId = BeanId.create("assembler", Role.class.getName());
Bean assembler = Bean.create(assemblerRoleId);
BeanId adminRoleId = BeanId.create("administrator", Role.class.getName());
Bean adminRole = Bean.create(adminRoleId);
adminRole.addReference("roles", deployerRoleId);
adminRole.addReference("roles", assemblerRoleId);
@Config(desc = "A binary tree")
@BinaryTreeConstraint
public class BinaryTree {
@Id(desc = "id of current node")
private String id;
@Config(desc = "value of current node")
@NotNull @Min(1)
private Integer value;
#! /usr/bin/perl
sub on_sel_grab {
my $query=quotemeta $_[0]-&gt;selection;
$query=~ s/\n/\\n/g;
$query=~ s/\r/\\r/g;
system( &quot;echo &quot; . $query . &quot; | xsel -i -b -p&quot; );
}
urxvt*perl-ext-common: default,matcher,clipboard
public class Item {
private String id;
private String name;
public Item(String id, String name) {
this.id = id;
this.id = name;
}
public String getId() { return id;}
public String getName() { return name; }
Item{id=1, name=Book}
try {
// throws implementation specific exception
} catch (InternalException e) {
throw new ApiException("reason", Throwables.getStackTraceAsString(e));
}
for (Item item : Iterables.concat(books, electronics)) {
// do something useful
}