Skip to content

Instantly share code, notes, and snippets.

@pradp
pradp / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@pradp
pradp / Application.java
Created September 19, 2014 16:40
Spring boot application class to exclude the data source auto configuration
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class,
HibernateJpaAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class })
@Configuration
@ComponentScan(basePackages = { "com.emc.tes" })
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
λ cf create-security-group host-redis security-group.json
λ cf bind-security-group host-redis micropcf-org micropcf-space
λ cf restart redis-example
@pradp
pradp / Docker commands
Last active April 3, 2017 12:29
Docker commands
To override the entry point for any of the docker images. In the vertx image you can first avoid executing vertx and bash in to the container and then execute later
docker run -it --entrypoint=/bin/bash vertx/vertx3-exec
--rm removes the image as soon as you exit the container. Clean!!!
docker run -it --rm --entrypoint=/bin/bash vertx/vertx3-exec
View running processes
$ sudo docker ps
@pradp
pradp / server.properties
Created April 7, 2018 13:48
Kafka server property file
broker.id={unique-number}
listeners=EXTERNAL://:9092,INTERNAL://:9093
advertised.listeners=EXTERNAL://{ELB-CNAME}:9092,INTERNAL://{my-ip}:9093
listener.security.protocol.map=INTERNAL:SASL_PLAINTEXT,EXTERNAL:SASL_PLAINTEXT
inter.broker.listener.name=INTERNAL
authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer
sasl.mechanism.inter.broker.protocol=PLAIN
sasl.enabled.mechanisms=PLAIN
super.users=User:{admin-username}
zookeeper.connect={znode-a-ip}:2181,{znode-b-ip}:2181,{znode-c-ip}:2181
@pradp
pradp / server-jaas.config
Last active April 7, 2018 14:31
Kafka server jaas config properties file
KafkaServer {
com.company.CustomServerLoginModule required
username={username}
password={password}
user_{username}={password}
//Any additional users to configure
};
import org.apache.kafka.clients.CommonClientConfigs;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.ProducerRecord;
import java.util.Properties;
import java.util.Random;
public class SampleProducer {
public static void main(String[] args) {
import org.apache.kafka.clients.CommonClientConfigs;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import java.util.Arrays;
import java.util.Properties;
public class SampleConsumer {
public static void main(String[] args) throws Exception {
KafkaClient {
com.company.CustomLoginModule required;
};
public class SampleProducer {
public static void main(String[] args) {
Properties props = new Properties();
props.put("bootstrap.servers", "kafka-a.company.com:9092,kafka-b.company.com:9092,kafka-c.company.com:9092");
props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SASL_SSL");
props.put("sasl.mechanism", "PLAIN");
//Few more props. Refer https://gist.github.com/pradp/a18312ab72e50117075131efc1a87629
Producer<String, String> producer = new KafkaProducer<String, String>(props);
Random rand = new Random();
for (int i = 0; i < 100; i++)