Skip to content

Instantly share code, notes, and snippets.

View milenkovicm's full-sized avatar
🤿

Marko Milenković milenkovicm

🤿
View GitHub Profile
@milenkovicm
milenkovicm / gist:2404485
Created April 17, 2012 08:20
git commands and aliases

Simplest way to git a list of conflicted files

$git ls-files -u | cut -f 2 | sort -u
$git ls-files -u | awk '{print $4}' | sort | uniq

or just add an alias

@milenkovicm
milenkovicm / gist:2205432
Created March 26, 2012 14:22
GIT .git/config - if you ever forget how to track remote branch
[core]
repositoryformatversion = 0
filemode = false
logallrefupdates = true
autocrlf = false
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
@milenkovicm
milenkovicm / ContainerInitializedObserver.java
Created March 17, 2012 21:26
[Java] CDI - observes conteiner initialized event
/*
* Copyright (c) 2012 Marko Milenkovic
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@milenkovicm
milenkovicm / DeploymentHelper.java
Created March 17, 2012 21:07
[Junit] Arquillian - deployment helper
/*
* Copyright (c) 2012 Marko Milenkovic
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@milenkovicm
milenkovicm / SmokeWarTest.java
Created March 17, 2012 20:42
[Junit] Arquillian - how to use maven resolver to resolve dependencies
package com.example;
import javax.inject.Inject;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
@milenkovicm
milenkovicm / ResourceReader.java
Created March 14, 2012 15:15
[Java] - Resource loader
package com.example.util;
import java.io.File;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class ResourceReader {
@milenkovicm
milenkovicm / WarSmokeTest.java
Created March 14, 2012 11:42
[Junit] Arquillian - how to export shrinkwrap archive
@RunWith(Arquillian.class)
public class WarSmokeTest {
@Deployment
public static Archive<?> createTestArchive() {
final MavenDependencyResolver resolver = DependencyResolvers.use(MavenDependencyResolver.class).loadMetadataFromPom("pom.xml");
final WebArchive archive = ShrinkWrap.create(WebArchive.class)
.addAsWebInfResource("META-INF/beans.xml")
///
@milenkovicm
milenkovicm / BeansXmlTest.java
Created March 12, 2012 11:54
[Junit] Arquillian - use of @ShouldThrowException(Exception.class) at @deployment method
package org.jboss.weld.tests.xml.broken.stereotype;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.BeanArchive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.junit.Test;
import org.junit.runner.RunWith;
@milenkovicm
milenkovicm / AnEasyMockTestClass.java
Created March 12, 2012 00:00
[Junit] EasyMock - few examples, how to use it
package acme;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.easymock.Capture;
import org.easymock.EasyMock;
import org.junit.AfterClass;
import org.junit.Before;
@milenkovicm
milenkovicm / eclipse_preferences_linux.epf
Created March 11, 2012 18:29
[eclipse] settings - user preference for fedora linux
#Sun Mar 11 18:21:01 GMT 2012
/instance/org.eclipse.jdt.ui/sp_cleanup.always_use_parentheses_in_expressions=false
/instance/org.eclipse.team.ui/org.eclipse.team.ui.first_time=false
/instance/org.eclipse.jdt.ui/cleanup.add_default_serial_version_id=false
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
/instance/org.eclipse.wst.xml.xpath.ui/org.eclipse.wst.xml.xpath.ui.xpath_custom_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
/instance/org.jboss.tools.jsf.ui/Use\ Large\ Icons\ -\ Columns=false
/instance/org.jboss.ide.eclipse.archives.ui/showProjectRoot=true
/instance/org.eclipse.jdt.ui/sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true