Skip to content

Instantly share code, notes, and snippets.

View HalitTalha's full-sized avatar

Halit Talha TÜRE HalitTalha

View GitHub Profile
@HalitTalha
HalitTalha / app.component.html
Created February 9, 2021 20:21
Angular PWA - html
<button *ngIf="shouldInstall()" class="install" (click)="installPWA()">Install as an application</button>
<button *ngIf="updateAvailable" class="update" (click)="reload()">Update available. Click to refresh</button>
@HalitTalha
HalitTalha / app.component.ts
Created February 9, 2021 20:19
Angular PWA - Available Updates
public updateAvailable: boolean;
constructor(private swUpdate: SwUpdate) {
this.swUpdate.available.subscribe(evt => {
this.updateAvailable = true;
});
}
public reload() {
this.swUpdate.activateUpdate().then(() => document.location.reload());
@HalitTalha
HalitTalha / app.component.ts
Created February 9, 2021 20:15
Angular PWA - Adding install button
public promptEvent;
@HostListener('window:beforeinstallprompt', ['$event'])
onbeforeinstallprompt(e) {
e.preventDefault();
this.promptEvent = e;
}
public installPWA() {
this.promptEvent.prompt();
@HalitTalha
HalitTalha / pom.xml
Created April 24, 2020 20:19
MavenShadePlugin transformer for log4j2 plugins cache file
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<!--$NO-MVN-MAN-VER$-->
<executions>
<execution>
<phase>package</phase>
<goals>
@HalitTalha
HalitTalha / log4j2.xml
Created April 24, 2020 11:47
log4j2.xml example for logstash-gelf usage
<Configuration status="TRACE" monitorInterval="180">
...
<!--CHANGE HOST AND PORT PROPERTIES ACCORDING TO YOUR NEEDS-->
<Appenders>
<Gelf name="gelf" host="udp:graylog.somedomain.com" port="12211" version="1.1" extractStackTrace="true" filterStackTrace="true" mdcProfiling="true" includeFullMdc="true" maximumMessageSize="8192" originHost="%host{fqdn}">
<!--THESE FIELD DEFINITIONS ARE NOT MANDATORY, YOU CAN USE DEFAULTS-->
<Field name="timestamp" pattern="%d{dd MMM yyyy HH:mm:ss,SSS}"/>
<Field name="level" pattern="%level"/>
<Field name="simpleClassName" pattern="%C{1}"/>
<Field name="className" pattern="%C"/>
@HalitTalha
HalitTalha / pom.xml
Last active April 24, 2020 11:50
logshtash-gelf for log4j2
<dependencies>
<dependency>
<groupId>biz.paluch.logging</groupId>
<artifactId>logstash-gelf</artifactId>
<version>1.14.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
@HalitTalha
HalitTalha / MatTableExporterDirective.ts
Created April 9, 2020 22:03
MatTableExporterDirective.ts gist for embedding in blog
import { AfterViewInit, Directive, Host, Optional, Renderer2, Self } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatTable, MatTableDataSource } from '@angular/material/table';
import { CdkTableExporter, DataExtractorService, ServiceLocatorService } from 'cdk-table-exporter';
import { Observable } from 'rxjs';
@Directive({
selector: '[matTableExporter]', // renamed selector but kept old version for backwards compat.
exportAs: 'matTableExporter'
})
@HalitTalha
HalitTalha / AppComponent.ts
Created April 9, 2020 20:45
Simple implementation of nativetable exporting for Angular Material Tables. SheetJs is employed
import { Component, ViewChild, ElementRef } from '@angular/core';
import * as XLSX from 'xlsx';
export class AppComponent {
@ViewChild('TABLE', { static: true }) table: ElementRef;
exportTable() {
const ws: XLSX.WorkSheet = XLSX.utils.table_to_sheet(this.table.nativeElement);
const wb: XLSX.WorkBook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
@HalitTalha
HalitTalha / JmsConfig.java
Created April 8, 2020 17:21
Demonstrates JmsConfig for Spring Batch JmsItemWriter & JMS Queue Connection via JNDI properties
import java.util.Properties;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.naming.Context;
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@HalitTalha
HalitTalha / context.xml
Created September 11, 2019 09:16
Tomcat DataSource Example For Oracle Connection
<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for additional
information regarding copyright ownership. The ASF licenses this file to
You under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific