Skip to content

Instantly share code, notes, and snippets.

View balvinder294's full-sized avatar
๐Ÿ˜Ž
Working Remotey

Balvinder Singh balvinder294

๐Ÿ˜Ž
Working Remotey
View GitHub Profile
package com.tekraze.kafka.web.websocket;
import static com.tekraze.kafka.config.WebsocketConfiguration.IP_ADDRESS;
import com.tekraze.kafka.web.websocket.dto.ActivityDTO;
import java.security.Principal;
import java.time.Instant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@balvinder294
balvinder294 / webSocketsSecurityConfiguration.java
Created March 15, 2020 12:21
Sample configuration for Security of web sockets In Spring - Tekraze
package com.tekraze.kafka.config;
import com.tekraze.kafka.security.AuthoritiesConstants;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.SimpMessageType;
import org.springframework.security.config.annotation.web.messaging.MessageSecurityMetadataSourceRegistry;
import org.springframework.security.config.annotation.web.socket.AbstractSecurityWebSocketMessageBrokerConfigurer;
@Configuration
@balvinder294
balvinder294 / Websocket-configuration.java
Created March 15, 2020 12:10
Sample confiuration for Websockets Configuration in Spring Boot - Tekraze.com
package com.tekraze.kafka.config;
import com.tekraze.kafka.security.AuthoritiesConstants;
import java.security.Principal;
import java.util.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.server.*;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
@balvinder294
balvinder294 / pom.xml
Last active March 15, 2020 11:58
Websocket Dependencies Spring Tekraze.com
<!-- Spring Socket Dependencies for Web Sockets -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-messaging</artifactId>
</dependency>
https://www.linuxbabe.com/mail-server/setting-up-dkim-and-spf
https://www.linuxbabe.com/mail-server/opendmarc-postfix-ubuntu
@balvinder294
balvinder294 / base64-.txt
Created February 17, 2020 06:40
Sample of base 64 url with Media Type and without Media Type
///// THe base 64 url with media type at start
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMEAAAEFCAMAAABtknO4AAABg1BMVEX////oTD3m5uZMS01PTU8AAADy8vIgICA4OzYPM0egoI7/zMnoSzza29o2Nzb6+vpGRUdBQEIwMDGFhYbIycmxsbLp6enoRzfi4uLv7+/nQzLnRTT0//+bmYnV1dXxTj6oqJgXFxfAwMDJQTT98vHnPiyzs7O3Oy//0s+9uq773tzmIwvW8/QvLS8kIyTY4+LZRzndzMn1sKoREREAL0f/UDvmNCKWlZZZWFp4d3gvMy32urX84+HraF1kZGTugngAFjQAITs2PkrpXVCko6TNzcPviYHvk4vsd2zwopzpVUjrhHvlYlbfrqrrMh5/f3+sPTMAACTRurspNjbwnJTltK/pHwDV/P3in5ndr6vxm5TgoZytPTpQZmi71NWUfHxsSE1QFRYqVWN/lJ0nGCgVFSl2O0NpcnsxSFpMYG1lhJBNN0TRTD0AAB8cKTs7QEyWQD8AEDO7lZbFqqmvpaVfZHBnNT5XOUR4OTTEYlnRf3kAITBGNzgMMzY6SVQVGxF+fXPkmaOGAAAgAElEQVR4nNVdiX/bxpXmAZJ2BBAAD4AAFTCiCZqlRFGiJB7mIcvEihQlU7Yju47jTbObbuy2Tupe2e5um/ZP3zkwuEmCEGSpz/kpJAHMvG/eMW/eHIhEwqJ+dHYWWmG3QTWapuV/aQhncjRKixu3zUZwYo/FKIAgD26bkcCEEUSLp7fNSGBiJ0WIgI7+6+pRS45iIbC3zUlQ2qBpJASxftucrE9spVKJROpjhCAqT26bn7WpNpleTFuVyBSZcpQu3jZDq2hwdjpp1SrG91ZUFmlRHg762BCi6h235dpcLhZlVZ32B8hkKzPc9PI0ImI1Es+BYtUsGO8Y6boSFeXxZANwyU6LetOfnWEh0ON6pK/K09Zts7qACAK
@balvinder294
balvinder294 / script.sh
Created January 10, 2020 17:29
FIx Broken Packages Ubuntu
sudo mv /var/lib/dpkg/status /var/lib/dpkg/_status/
&& touch /var/lib/dpkg/status /
&& sudo apt update && sudo apt upgrade
@balvinder294
balvinder294 / Kafa-compose-single-node.yml
Created January 10, 2020 06:21
SIngle Kafka And Zookeeper in Docker Compose
# One Kafka container and One Zookeeper COntainer with volumes configured
version: '2'
services:
zookeeper:
image: confluentinc/cp-zookeeper:5.3.0
container_name: zookeeper
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
@balvinder294
balvinder294 / video-convert-mp4.java
Last active July 25, 2022 10:14
Code for video conversion with JAVA
Convert a video to Mp4(MPEG-4 AVC) and AAC audio
/* Step 1. Declaring source file and Target file */
File source = new File("source.avi");
File target = new File("target.mp4");
/* Step 2. Set Audio Attrributes for conversion*/
AudioAttributes audio = new AudioAttributes();
audio.setCodec("aac");
// here 64kbit/s is 64000
@balvinder294
balvinder294 / post-file.java
Created November 24, 2019 14:27
Sample method for posting a multipart file to rest api with OkHttp
/**********
* Here is a method showing use of OkHttp for posting a multipart form data
*
* Here RPResumeResponseDTO is a custom DTO being used in the project
* For taking file from rest api endpoint we are using as a multipart file parameter
**********/
/**************Steps *******************/
RPResumeResponseDTO postResumeToRPServer(MultipartFile file) throws IOException {
log.debug("Request to post file : {}",file.getOriginalFilename());