Skip to content

Instantly share code, notes, and snippets.

View senoritadeveloper01's full-sized avatar

Nil Seri senoritadeveloper01

View GitHub Profile
@senoritadeveloper01
senoritadeveloper01 / server-send-events.component.ts
Created April 29, 2022 14:04
Angular SSE component - detect back to online status
isOnlineSubscription: Subscription;
ngOnInit() {
...
this.checkIfBackToOnline();
}
ngOnDestroy() {
...
this.isOnlineSubscription.unsubscribe();
@senoritadeveloper01
senoritadeveloper01 / OpenApiConfig.java
Created April 25, 2022 11:09
OpenAPI Configuration Class in Spring Boot
package com.senoritadev.bookstore.configuration.documentation;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@senoritadeveloper01
senoritadeveloper01 / BookRestController.java
Created April 25, 2022 10:31
OpenAPI Documentation Annotations in Spring Boot
package com.senoritadev.bookstore.rest;
import com.senoritadev.bookstore.model.BookInfo;
import com.senoritadev.bookstore.service.BookService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
@senoritadeveloper01
senoritadeveloper01 / util.service.ts
Created April 24, 2022 17:28
File Upload Process Http Event Types (Angular)
isHttpProgressEvent(event: HttpEvent<unknown>): event is HttpProgressEvent {
return (
event.type === HttpEventType.DownloadProgress ||
event.type === HttpEventType.UploadProgress
);
}
@senoritadeveloper01
senoritadeveloper01 / file-upload.component.ts
Last active April 24, 2022 17:19
File Upload Process Component Methods (Angular)
startUpload(): void {
const filesToUpload = [];
this.files.forEach(f => {
const uuid = UtilService.generateUUID();
filesToUpload.push({
'name': f.name,
'size': f.size,
'uuid': uuid
});
this.fileUUIDList.push(uuid);
@senoritadeveloper01
senoritadeveloper01 / upload.service.ts
Created April 24, 2022 17:13
File Upload Process Http Parameters (Angular)
uploadFile(fileInfo: any): Observable<any> {
const headers: HttpHeaders = new HttpHeaders({
'Accept': 'application/json',
'Content-Type': fileInfo.file.type,
'X-Meta-Strategy': '1',
'X-File-Size-Sig': fileInfo.signature
});
return this.http.put(fileInfo.url, fileInfo.file, {
headers: headers,
reportProgress: true,
@senoritadeveloper01
senoritadeveloper01 / ShellSort.java
Created January 19, 2022 20:33
Shell Sort Implementation in Java
public static void shellSort(int arr[]) {
for (int i = arr.length / 2; i > 0; i /= 2) {
for (int j = i; j < arr.length; j += 1) {
int value = array[j];
int k;
for (k = j; k >= i && array[k - i] > temp; k -= i) {
array[k] = array[k - i];
}
array[k] = value;
@senoritadeveloper01
senoritadeveloper01 / HeapSort.java
Created January 19, 2022 19:53
Heap Sort Implementation in Java
public static void heapSort(int arr[]) {
for (int i = arr.length / 2 - 1; i >= 0; i--) {
heapify(arr, i);
}
for (int i = arr.length - 1; i >= 0; i--) {
int temp = arr[0];
arr[0] = arr[i];
arr[i] = temp;
@senoritadeveloper01
senoritadeveloper01 / BucketSort.java
Created January 19, 2022 19:30
Bucket Sort Implementation in Java
public void bucketSort(float[] arr, int bucketCount) {
if (bucketCount <= 0) {
return;
}
List<Float>[] bucket = new ArrayList[bucketCount];
for (int i = 0; i < bucketCount; i++) {
bucket[i] = new ArrayList<Float>();
}
@senoritadeveloper01
senoritadeveloper01 / RadixSort.java
Created January 19, 2022 19:01
Radix Sort Implementation in Java
private static void radixSort(int array[]) {
int max = array[0];
for (int i = 1; i < array.length; i++) {
if (array[i] > max) {
max = array[i];
}
}
for (int i = 1; max / i > 0; i *= 10) {
countingSort(array, i);