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) {
Process: Plex Media Server [2724]
Path: /Applications/Plex Media Server.app/Contents/MacOS/Plex Media Server
Identifier: com.plexapp.plexmediaserver
Version: 0.9.8.18 (0.9.8.18.290-11b7fdd)
Code Type: X86-64 (Native)
Parent Process: launchd [175]
Responsible: Plex Media Server [2724]
User ID: 501
Date/Time: 2014-01-18 19:19:07.842 -0200
@guilhermesilveira
guilhermesilveira / halmoni.c
Created October 3, 2013 14:26
1. C언어 Stack and Dynamic allocation test when using fork 2. C언어 보무프로세스 죽는 test
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
int main()
{
pid_t pid, pid2;
if( (pid = fork()) < 0 ) {
perror("fork failed");
@guilhermesilveira
guilhermesilveira / Example.java
Last active December 24, 2015 04:49
custom serialization
public class Controller {
public void x() {
// custom whatever
result.from(object).with(new RafaelRuleOfNonArrayReplicationInJson());
// music include
result.from(object).with(include("musica"));
@guilhermesilveira
guilhermesilveira / BaseEnvironments.java
Last active December 23, 2015 22:49
points: . type safe . type safe . no missing parameter . option to create MANDATORY parameter . applicationscoped if the custom vraptor plugin is applicationscoped, the plugin docs will let you know...
/**
* My application desires
**/
@ApplicationScoped // PROBABLY IMPORTANT, or will CDI read the parent one?
@Environment({"development", "test", "acceptance"})
public class AcceptanceAndTest extends EmailConfig {
// mandatory configuration
public File getBaseDir() {
return new File("/tmp");
@guilhermesilveira
guilhermesilveira / ApplicationHelper.java
Last active April 24, 2018 17:31
View helper example
public class ApplicationHelper implements ViewHelper {
private final PrettyTimeFormatter formatter;
public ApplicationHelper(PrettyTimeFormatter formatter) {
this.formatter = formatter;
}
public String format(AbstractInstant instant) {
return formatter.format(instant);
@guilhermesilveira
guilhermesilveira / Hibernate.java
Last active December 16, 2015 04:49
SQL Injection Example
Criteria criteria = session.createCriteria(User.class);
criteria.add(eq("email", email);
criteria.add(eq("password", password);
User found = criteria.setMaxResults(1).uniqueResult();
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);
@guilhermesilveira
guilhermesilveira / robot.js
Created December 5, 2012 16:55 — forked from fabiopimentel/robot.js
[CAELUM TEAM]Megatron
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.clone();
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);