Skip to content

Instantly share code, notes, and snippets.

View iamitshri's full-sized avatar
🦉
Focusing

iamitshri iamitshri

🦉
Focusing
View GitHub Profile
@iamitshri
iamitshri / gulpfile.js
Created July 12, 2017 21:00
gulp snippet
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var runSequence = require('run-sequence');
var fs = require('fs');
var del = require('del');
var babel = require('gulp-babel');
@iamitshri
iamitshri / webpack.config.js
Created July 12, 2017 21:06
Webpack snippet to help bundle Bootstrap, jquery and JS files
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
context: __dirname + "/webapp",
entry: {
advancedSearch: [
'./js/advancedSearch.js'
]
@iamitshri
iamitshri / kata.java
Last active July 12, 2018 20:05
Java: Convert a give util date to a util date at the start of the day
package katas;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.util.Calendar;
import java.util.Date;
public class Main {
@iamitshri
iamitshri / oracle functions notes.sql
Last active September 11, 2018 16:21
Oracle functions
select initcap('assasa') from dual;
select substr('asasda',-6,3) from dual;
select concat('concat','works') from dual;
select trim(' asa ') from dual;
select trim(Leading 'a' from 'aaaadfdfaaa') from dual;
select trim(Trailing 'a' from 'aaaadfdfaaa') from dual;
select trim(both 'a' from 'aaaadfdfaaa') from dual;
select instr('12343','3',3,2) from dual;
select lpad('asfd',10,'$'),rpad('dad',10,'%') from dual;
select replace('1234','1234','9') from dual;
@iamitshri
iamitshri / setting the default time zone.java
Created September 11, 2018 16:26
Setting the default timezone for spring boot app
@PostConstruct
void started() {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
}
@iamitshri
iamitshri / commands.txt
Last active October 5, 2018 17:15
Maven Commands that I want to remember
What do these option means?
-B -f pom.xml -X clean install
@iamitshri
iamitshri / eclipse plugins.txt
Last active October 8, 2018 17:04
Eclipse STS source code analysis tools for java
static code analysis tools
Unnecessary Code Detector
https://marketplace.eclipse.org/category/free-tagging/find-unused-code
Findbugs
https://marketplace.eclipse.org/content/findbugs-eclipse-plugin
spotbugs
@iamitshri
iamitshri / annotationReflectionExample.java
Created October 9, 2018 21:02
Read Annotations on class using Reflection
// Get annotations on the class object
Annotation[] annotations = classobject.getClass()
.getAnnotations();
for (Annotation annotation : annotations) {
log.debug("annotation type: {}", annotation.annotationType());
Class<? extends Annotation> type = annotation.annotationType();
for (Method method : type.getDeclaredMethods()) {
Object val = method.invoke(annotation, (Object[]) null);
log.debug("method name: {}, return value:{} return type:{}", method.getName(), val, val.getClass()
.getName());
@iamitshri
iamitshri / RestResponseEntityExceptionHandler.java
Created October 9, 2018 21:43
Spring Boot Exception Handler that parses Response status annotation on the Exception class
package edu.wgu.dm.config;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;