Skip to content

Instantly share code, notes, and snippets.

@m-cakir
m-cakir / app.js
Last active April 8, 2018 11:40
Hapi playground
'use strict';
const Hapi = require('hapi');
const HapiSwagger = require('hapi-swagger');
const Models = require('./models');
const Routes = require('./routes');
const Pack = require('./package');
const Fixtures = require('sequelize-fixtures');
const server = Hapi.server({
@m-cakir
m-cakir / movie.js
Created April 8, 2018 11:48
Hapi playground routes/movie.js
'use strict';
const Models = require('../models');
const Joi = require('joi');
const Boom = require('boom');
module.exports = function () {
return [{
method: 'GET',
path: '/movies',
@m-cakir
m-cakir / gist:433e24cfe0b2af280f9fed527f0a4551
Created April 24, 2018 11:30 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@m-cakir
m-cakir / CustomResponseEntityExceptionHandler.java
Created May 23, 2018 12:31 — forked from matsev/CustomResponseEntityExceptionHandler.java
Generic response error handling using @ControllerAdvice
@ControllerAdvice
public class CustomResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
@Override
protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) {
List<FieldError> fieldErrors = ex.getBindingResult().getFieldErrors();
List<ObjectError> globalErrors = ex.getBindingResult().getGlobalErrors();
List<String> errors = new ArrayList<>(fieldErrors.size() + globalErrors.size());
String error;
for (FieldError fieldError : fieldErrors) {
@m-cakir
m-cakir / LoggingOutInterceptor.java
Last active June 3, 2022 00:47
Apache CXF - Interceptor Example (Inbound/Outbound Message)
package com;
import java.lang.reflect.Method;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
@m-cakir
m-cakir / pom.xml
Created July 26, 2018 10:02 — forked from timmolderez/pom.xml
Adding dependencies to local .jar files in pom.xml
If you'd like to use a .jar file in your project, but it's not available in any Maven repository,
you can get around this by creating your own local repository. This is done as follows:
1 - To configure the local repository, add the following section to your pom.xml (inside the <project> tag):
<repositories>
<repository>
<id>in-project</id>
<name>In Project Repo</name>
<url>file://${project.basedir}/libs</url>
@m-cakir
m-cakir / Spring_propagations.md
Created July 30, 2018 08:38 — forked from rponte/Spring_propagations.md
Differences between PROPAGATION_REQUIRES_NEW and PROPAGATION_NESTED propagation in Spring transactions
  • PROPAGATION_REQUIRES_NEW starts a new, independent "inner" transaction for the given scope. This transaction will be committed or rolled back completely independent from the outer transaction, having its own isolation scope, its own set of locks, etc. The outer transaction will get suspended at the beginning of the inner one, and resumed once the inner one has completed.

Such independent inner transactions are for example used for id generation through manual sequences, where the access to the sequence table should happen in its own transactions, to keep the lock there as short as possible. The goal there is to avoid tying the sequence locks to the (potentially much longer running) outer transaction, with the sequence lock not getting released before completion of the outer transaction.

  • PROPAGATION_NESTED on the other hand starts a "nested" transaction, which is a true subtransaction of the existing one. What will happen is that a savepoint will be taken at the start of the nested transaction. I
import org.apache.axis.AxisFault;
import org.apache.axis.Handler;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.SimpleChain;
import org.apache.axis.SimpleTargetedChain;
import org.apache.axis.configuration.SimpleProvider;
import org.apache.axis.handlers.BasicHandler;
import org.apache.axis.transport.http.HTTPSender;
import org.apache.axis.transport.http.HTTPTransport;
@m-cakir
m-cakir / Component.ts
Last active November 24, 2018 12:59
Angular 2+ File Upload
import { Component, OnInit } from '@angular/core';
import { FormGroup, Validators, FormBuilder } from '@angular/forms';
@Component({
templateUrl: './form.html'
})
export class Component implements OnInit {
form: FormGroup;
@m-cakir
m-cakir / AppModule.ts
Last active October 31, 2018 13:21
Angular 2+ Custom Decorator for Lifecycle Hooks
import { Title } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { InjectorModule } from './InjectorModule';
@NgModule({
...
...
imports: [
..
...