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
@balvinder294
balvinder294 / fetch-file-from-url-spring-boot.java
Last active April 12, 2024 10:51
Fetch Image from URL and save locally in Spring Boot(Java)
Url imageUrl = new Url("https://site.com/image.jpeg"); // Sample url, replace with yours
String destinationFile = "sample.jpg";
/*******************Multipart Upload Method*********************************
** To resources like minio or DB
***************************************************************************/
/********
* Step 1
@balvinder294
balvinder294 / zabbix-docker-compose.yml
Created July 11, 2019 11:39
Zabbix running in Docker Compose with Postgres, Graffana, Adminer
version: '3.1'
services:
postgres-server: # The Postgres Database Service
image: postgres:latest
restart: always
environment: # Username, password and database name variables
POSTGRES_USER: zabbix
POSTGRES_PASSWORD: zabbix
POSTGRES_DB: zabbix
PG_DATA: /var/lib/postgresql/data/pgdata #data storage
@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());
@balvinder294
balvinder294 / oauth-popup.ts
Last active March 22, 2023 10:19
Popup window for Oauth Login
// authorization code and tokens
authorizationCode: string;
oAuthToken: string;
oAuthVerifier: string;
// popup related
private windowHandle: Window; // reference to the window object we will create
private intervalId: any = null; // For setting interval time between we check for authorization code or token
private loopCount = 600; // the count until which the check will be done, or after window be closed automatically.
private intervalLength = 100; // the gap in which the check will be done for code.
@balvinder294
balvinder294 / key-value-extract.java
Created March 31, 2020 13:02
Sample Code for AWS Textract Key-Value Extraction JAVA AWS SDK --- Tekraze
public Map<String, String> getKeyValueRelationShipByBlocks(List<Block> blocks) {
Map<String, Map<String, Block>> keyValueBlockMap = getKeyValueBlockMap(blocks);
getKeyValueRelationShip(keyValueBlockMap);
return null;
}
Block findValueBlock(Block keyBlock, Map<String, Block> valueMap) {
log.debug("Find value Block ");
Block valueBlock = null;
@balvinder294
balvinder294 / index.html
Created January 24, 2023 16:56
A sample to use Browserify bundel containing Npm module in the browser | Tekraze.com
<script src="./example.js"></script>
<script>
async function someMethod() {
const res = window.Buffer.from('somestring');
}
</script>
Shared Hosting Dedicated Hosting
1. Shared Resources 1. Dedicated Resources
2. Cheap than Dedicated 2. Costlier than Dedicated
3. Mostly no root access 3. Root access available
4. Less control over resources and software 4. More control over resources and software
5. No custom software as they are shared by everyone 5. We can have custom software as there is no sharing
6. Good for small projects/testing sites and web apps 6. Good for large-scale and enterprise web apps and sites
7. Most storage is Hard Disk Drives 7. Storage is mostly SSD
8. No Customizable environment 8. Customizable environment
@balvinder294
balvinder294 / apple-authorize.java
Last active October 25, 2022 07:10
Authorize Method for apple sign in
/*************** Imports ***************/
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.json.JSONObject;
import org.springframework.cloud.cloudfoundry.com.fasterxml.jackson.databind.ObjectMapper;
private static String APPLE_AUTH_URL = "https://appleid.apple.com/auth/token";
@balvinder294
balvinder294 / JWTToken.java
Created July 27, 2020 07:05
JWT Token gneration for apple Sign in verification
/***Imports ****/
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import java.security.PrivateKey;
import java.security.PublicKey;
import io.jsonwebtoken.JwsHeader;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import java.util.Date;
@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