Skip to content

Instantly share code, notes, and snippets.

View bibryam's full-sized avatar
🏠
Working from home

Bilgin Ibryam bibryam

🏠
Working from home
View GitHub Profile
@bibryam
bibryam / ulimit.sh
Created January 10, 2019 13:31 — forked from Maarc/ulimit.sh
Bash script updating the ulimits
#!/usr/bin/env bash
# Automating https://blog.dekstroza.io/ulimit-shenanigans-on-osx-el-capitan/
echo "Updating the ulimits on OSX to be able to run RHAMT tests."
sudo bash -c 'cat >/Library/LaunchDaemons/limit.maxfiles.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
@bibryam
bibryam / CamelOracle.java
Last active July 19, 2018 20:13
A Camel route that listens for CallbackGetBTCCap events and calls setBTCCap with a random value
@Override
public void configure() throws Exception {
from("web3j://http://127.0.0.1:7545?operation=ETH_LOG_OBSERVABLE&topics=" + topics)
.to("log:com.ofbizian.CallbackGetBTCCap?level=INFO&showAll=true")
.setHeader(OPERATION, constant(ETH_SEND_TRANSACTION))
.setHeader(FROM_ADDRESS, constant("0xc8CDceCE5d006dAB638029EBCf6Dd666efF5A952"))
.setHeader(TO_ADDRESS, constant("0x484982345fD584a0a16deC5F9ba330f6383af3d9"))
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
apiVersion: batch/v2alpha1
kind: ScheduledJob
metadata:
name: hello
spec:
schedule: 0/1 * * * ?
jobTemplate:
spec:
template:
spec:
@bibryam
bibryam / CamelHystrixCircuitBreaker.java
Last active May 24, 2016 22:56
Camel Hystrix Circuit Breaker
public class ClientRoute extends RouteBuilder {
@Override
public void configure() {
from("timer:trigger?period=1s")
.log(" Client request: ${body}")
.hystrix()
.to("http://localhost:9090/service1")
// use onFallback() to provide a repsonse message immediately: .transform().simple("Fallback ${body}")
// use onFallbackViaNetwork() when there is a 2nd service call
@bibryam
bibryam / CamelCircuitBreaker.xml
Created May 24, 2016 21:58
Camel Circuit Breaker
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:start"/>
<loadBalance>
<circuitBreaker threshold="2" halfOpenAfter="1000">
<exception>MyCustomException</exception>
</circuitBreaker>
<to uri="mock:result"/>
</loadBalance>
</route>
@bibryam
bibryam / batch_sql.java
Last active January 21, 2016 10:24
SQL component batch insert
return new RouteBuilder() {
public void configure() throws Exception {
from("direct:start")
.aggregate(header("PROD_TYPE"), new SQLStrategy()).completionSize(100).completionTimeout(1000)
.to("sql:insert into products (price, description) values (#, #)?batch=true");
}
};
@bibryam
bibryam / RequestQualifier.drl
Last active October 16, 2015 14:00
Complex Event Processing Rule to mark errors as critical
package org.kie.example.project1;
rule "Mark a request as critical when there are 5 or more in 10 seconds. There should be at most 1 critical per 10 minutes"
when
$requestQualifier: RequestQualifier(processed == false)
Number( intValue >=5 ) from accumulate($r: RequestQualifier( ) over window:time( 10s ),count( $r ) )
Number( intValue ==0 ) from accumulate($r: RequestQualifier( critical == true) over window:time(10m ),count( $r ) )
then
modify($requestQualifier) {
setProcessed(true),
@bibryam
bibryam / ErrorHandlingProcess.java
Last active October 16, 2015 13:32
Camel jBPM Error Handler Route
public void configure() {
from("timer://trigger?fixedRate=true&period=500&repeatCount=10").routeId("mainRoute")
.to("log:com.ofbizian.jbpm.before?showAll=true&multiline=true")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
throw new RuntimeException("Something went wrong");
}
});
@bibryam
bibryam / IdempotentRoute.java
Created August 20, 2014 22:54
Clustered Idempotent Camel Route
public class IdempotentRoute extends RouteBuilder {
private static final transient Logger LOGGER = LoggerFactory.getLogger(IdempotentRoute.class);
private InfinispanIdempotentRepository infinispanRepo;
private int port;
@Override
public void configure() throws Exception {
from("restlet:http://localhost:" + port + "/idempotent/{key}?restletMethods=GET")
<plugin>
<groupId>com.ofbizian</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<images>
<image>
<name>dockerfile/redis</name>
<hostConfig>
<![CDATA[