Skip to content

Instantly share code, notes, and snippets.

@malys
malys / jackson.java
Last active November 30, 2017 10:20
[Jackson Tips] #java
/*
From https://stackoverflow.com/questions/12046786/jackson-json-custom-serialization-for-certain-fields
http://www.mkyong.com/java/jackson-streaming-api-to-read-and-write-json/
*/
//Field Serialization
public class Person {
public String name;
public int age;
@JsonSerialize(using = IntToStringSerializer.class, as=String.class)
public int favoriteNumber:
@malys
malys / applyCall.js
Last active November 30, 2017 10:19
[Apply vs Call] #javascript
//From http://stackoverflow.com/questions/1986896/what-is-the-difference-between-call-and-apply
/*The main difference is that apply lets you invoke the function with arguments as an array;
call requires the parameters be listed explicitly.
See here and here.
Pseudo syntax: theFunction.apply(valueForThis, arrayOfArgs)
theFunction.call(valueForThis, arg1, arg2, ...)
Sample code: */
function theFunction(name, profession) {
alert("My name is " + name + " and I am a " + profession + ".");
@malys
malys / dropColumn.sql
Last active November 30, 2017 10:19
[SQL Tips] #sql
IF EXISTS ( SELECT * FROM information_schema.columns WHERE table_name = 'country' AND column_name = 'created_at' AND table_schema = DATABASE() ) THEN
ALTER TABLE `country` DROP COLUMN `created_at`;
END IF;
Because DROP COLUMN IF EXISTS isn't supported by MySQL.
@malys
malys / GIT.sh
Last active March 6, 2018 08:23
[Git Tips] #git
#SSL ignore
set GIT_SSL_NO_VERIFY=true
##LOG
# Difference de commit entre deux branch
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative master..branch-X
git log --graph --pretty=format:"%Cred%h%Creset - %C(cyan)%an%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset" --abbrev-commit --date=relative --since="2 day ago"
##RESET
#Annule les commits après H-2
@malys
malys / equalstoString.java
Last active November 30, 2017 10:18
[Guava Tips] #java #guava
import com.google.common.base.Objects;
public class Address {
...
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
@malys
malys / jasmineTestSnippets.json
Last active November 30, 2017 09:53
[Jasmine Snippets] #javascript #jasmine
[
{
"name":"After Each",
"trigger":"Jaft",
"usage":"Jaft",
"inline":true,
"description":"Jasmine After Each",
"template":"afterEach (function(){\n$${body}\n{\n"
},
{
@malys
malys / minified.js
Last active November 30, 2017 09:36
[Semver tests] #semver #javascript #nodejs
setTimeout(function(){require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var process=module.exports={};process.nextTick=function(){var canSetImmediate=typeof window!=="undefined"&&window.setImmediate;var canMutationObserver=typeof window!=="undefined"&&window.MutationObserver;var canPost=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(canSetImmediate){return function(f){return window.setImmediate(f)}}var queue=[];if(canMutationObserver){var hiddenDiv=document.createElement("div");var observer=new MutationObserver(function(){var queueList=queue.slice();que
@malys
malys / artillery.sh
Last active November 16, 2023 16:02
[Keycloak Use cases] #keycloak #java #authentification #artillery
# https://artillery.io/docs/cli-reference/
set DEBUG=http* | artillery run -k --target host -o h:\result.json scripts && artillery report h:\result.json
@malys
malys / clusterApp.puml
Last active November 30, 2017 10:42
[Keycloak diagram] http://uml.mvnsearch.org/github/ +raw url #keycloak #diagram
@startuml
autonumber
title __Cluster of application__ OpenID flow
box "Frontend" #Violet
participant User1
end box
box "Application 1" #LightBlue
participant LoadBalancer
participant Node1
@malys
malys / .gitignore
Created January 25, 2018 14:12
[Git ignore] #git
/.idea/
/.classpath
/.project
/.settings/
*.iml
/dependency-reduced-pom.xml
/target/