Skip to content

Instantly share code, notes, and snippets.

View silentsudo's full-sized avatar

Ashish Agre silentsudo

  • Bangalore
View GitHub Profile
package in.silentsudo.springintegrations.jms;
import jakarta.jms.ConnectionFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.jms.ChannelPublishingJmsMessageListener;
@silentsudo
silentsudo / produst-search.json
Created January 15, 2023 06:02
should match search as you type
DELETE products
PUT products
{
"mappings": {
"properties": {
"title": {
"type": "search_as_you_type"
}
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1
SELECT f.id as feed_id, u.name, u.email,
(select count(*) FROM jpatest.likes where feed_id = f.id) as likes_count,
(select count(*) FROM jpatest.comments where feed_id = f.id) as comments_count
FROM feeds f
LEFT JOIN users u
ON f.user_id = u.id
WHERE u.id = 12055;
SELECT
id,
address,
(6371 *
ACOS(COS(RADIANS(12.972442)) * COS(RADIANS(latitude)) * COS(RADIANS(longitude) -
RADIANS(77.580643)) + SIN(RADIANS(12.972442)) * SIN(RADIANS(latitude)))) AS distance
FROM
address
HAVING distance < 5
ORDER BY distance
SELECT f.id, u.email,
count(distinct l.id) as likes_count,
count(distinct c.id) as comments_count
FROM feeds f
INNER JOIN users u ON f.user_id = u.id
INNER JOIN likes l on l.feed_id = f.id
left join comments c on c.feed_id = f.id
WHERE u.id = 12055
group by f.id order by comments_count asc;
@silentsudo
silentsudo / completable-futures-example.java
Created June 19, 2021 03:45
example showing simple use of completable futures
package examples;
import java.time.Duration;
import java.time.LocalTime;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@silentsudo
silentsudo / random-string.sh
Created May 29, 2021 14:07
ubuntu-random-string
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1
@silentsudo
silentsudo / twitter-input-plugin.conf
Created May 20, 2021 06:41
logstash twitter input plugin
input {
twitter {
consumer_key => "${TWITTER_KEY}"
consumer_secret => "${TWITTER_SECRET}"
oauth_token => "${TWITTER_OAUTH_TOKEN}"
oauth_token_secret => "${TWITTER_OAUTH_SECRET}"
ignore_retweets => true
full_tweet => true
keywords=> ["java", "springboot"]
}
@silentsudo
silentsudo / HibernateEventEntityListener.java
Created March 21, 2021 16:07
hibernate-entity-event-listener
package com.example.samplejdbctemplatecall;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.boot.Metadata;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.event.service.spi.EventListenerGroup;