View RuleEngine.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (isUsed(usersHouse.cookingElectricStovePlates) && (isUsed(usersHouse.cookingLPGstovePlates))){//yes the user uses an electric plates and LPG plates | |
addSuggestion("I see you are using LPG gas in combination with an electric stove") | |
} | |
else if (isUsed(usersHouse.cookingElectricStovePlates))//yes the user uses an electric plates but not LPG gas | |
def percent = percent(usersHouse.cookingElectricStovePlates , perfectHouse.cookingLPGstovePlates) | |
if (percent > 150){ | |
addSuggestion("I see you are not using LPG gas, perhaps you should switch and you are using more than 150 % of the IES house") | |
} | |
else if (percent > 110){ | |
addSuggestion("I see you are not using LPG gas, perhaps you should switch") |
View AuctionItemExternalWorker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Stateless | |
public class AuctionItemExternalWorker { | |
@EJB | |
AuctionItemService service; | |
@EJB | |
AuditServiceAudit audit; | |
public void setMinBid(long bidId,long minBidCents) { | |
audit.auditSetMinBid(bidId,minBidCents); | |
service.setMinBid(bidId,minBidCents); | |
} |
View gist:7301662
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import com.sun.jersey.api.container.httpserver.HttpServerFactory; | |
import com.sun.jersey.api.core.PackagesResourceConfig; | |
import com.sun.jersey.api.core.ResourceConfig; | |
import com.sun.net.httpserver.HttpServer; | |
public class RunRest { | |
static final String BASE_URI = "http://localhost:9999/rest/"; |
View ConsumeHeap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConsumeHeap { | |
public static void main(String []args) throws IOException{ | |
HashMap<Long,Integer> hugeMap = new HashMap<>(); | |
Random rand = new Random(System.currentTimeMillis()); | |
for (int count=0;count <5000000;count++){ | |
long time = System.currentTimeMillis(); | |
hugeMap.put(time, rand.nextInt()); | |
} | |
System.out.println("Done"); |
View App.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class App { | |
public void createPrimativeInteger(){ | |
int x = 100000000; | |
} | |
public void createObjectIntegerNonAutoBoxing(){ | |
int x = 200000000; | |
} | |
public void createObjectIntegerAutoBoxing(){ | |
Integer x = 300000000; |
View gist:4829208096c488ad4c3d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Java 8 Java 8 G1GC Java 9 Java 9 G1GC | |
DynamicLanguages.groovy 402.142 352.266 397.495 370.121 | |
ExceptionsBenchMark.throwRuntimeException 885181.859 823326.931 910622.671 843228.203 | |
GeneratePoiWorkBook.generatePoiXLSWorkBook 34205.392 28162.636 35129.546 28693.55 | |
GeneratePoiWorkBook.generatePoiXLSXWorkBook 1125.074 980.061 1172.468 1012.47 | |
GeneratePrimeNumbersWithForLoop.generatePrime 231035.868 230904.102 231405.021 230599.11 | |
Jackson.jsonMashal 30019.081 22232.937 31908.426 24242.968 | |
Jackson.jsonUnmashal 26942.264 20443.724 26736.986 22404.13 | |
Jackson.xmlMashalJackson 22868.064 19657.647 23112.766 19947.204 | |
Jackson.xmlMashalJacksonStatic 691051.644 441105.658 745753.342 487013.862 |
View JMHJackson.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static AtomicInteger counter = new AtomicInteger(1); | |
public static final String user1JsonStart = "{\n" | |
+ " \"name\" : { \"first\" : \"Joe\", \"last\" : \"Sixpack"; | |
public static final String user1JsonEnd = "\" },\n" | |
+ " \"gender\" : \"MALE\",\n" | |
+ " \"verified\" : false,\n" | |
+ " \"userImage\" : \"Rm9vYmFyIQ==\"\n" | |
+ "}"; |
View POI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<String> list = new ArrayList<>(); | |
for (int count = 0; count < 60000; count++) { | |
list.add("T " + count); | |
} | |
SXSSFWorkbook workbook = new SXSSFWorkbook(); | |
SXSSFSheet sheet = workbook.createSheet("FIELD OPERATIONS TRACKER"); | |
for (int i = 0; i < list.size(); i++) { | |
SXSSFRow rowHeader = sheet.createRow(i); | |
for (int cellcount = 0; cellcount < 85; cellcount++) { | |
SXSSFCell cell = rowHeader.createCell(cellcount); |
View log4j2.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Configuration status="WARN" name="API" monitorInterval="30"> | |
<Appenders> | |
<RollingRandomAccessFile name="CatchAll" fileName="logs/all.log" immediateFlush="false" append="true" FilePattern="logs/$${date:yyyy-MM}/all-%d{yyyy-MM-dd}-%i.log.gz"> | |
<PatternLayout> | |
<Pattern>%d %m%n</Pattern> | |
</PatternLayout> | |
<Policies> | |
<TimeBasedTriggeringPolicy interval="1" modulate="true" /> | |
<SizeBasedTriggeringPolicy size="2 GB"/> |
View DuplicateSumTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DuplicateSumTest { | |
@Test | |
public void sumNonDuplicates() { | |
Assert.assertEquals("", 3, sumNonDuplicates(new int[]{1, 2})); | |
} | |
@Test | |
public void sumDuplicates() { | |
Assert.assertEquals("", 3, sumNonDuplicates(new int[]{2, 1, 2, 1})); | |
} |
OlderNewer