This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Setup the client | |
OkHttpClient client = new OkHttpClient.Builder() | |
.cookieJar(new CookieJar() { | |
@Override | |
public void saveFromResponse(HttpUrl url, List<Cookie> cookies) { | |
} | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- pom.xml ---> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.tomcat.maven</groupId> | |
<artifactId>tomcat7-maven-plugin</artifactId> | |
<version>2.2</version> | |
<configuration> | |
<path>/memento</path> | |
<port>9999</port> | |
<contextFile>src/main/webapp/META-INF/context.xml</contextFile> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.context.annotation.Configuration; | |
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | |
@Configuration | |
public class WebConfiguration extends WebSecurityConfigurerAdapter | |
{ | |
@Override | |
protected void configure(HttpSecurity http) throws Exception |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#service monitoring | |
#check if the url responds 200 in 60 seconds | |
timeout -s SIGTERM 60 curl -I https://youurl.com | grep '200 OK' | |
#> /dev/null | |
a=$(echo $?) | |
if test $a -ne 0 | |
then | |
echo "tried to restart" > laststatus.txt | |
echo "restart tomcat service" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Map; | |
/* | |
* This is a quick and dirty utility class to transform some keys | |
* that use dot notation (i.e. properties file keys) to a hierarchical | |
* structure like a java.util.Map. | |
* Usefull to transform a properties file to a json. | |
*/ | |
public class DotNotationToMap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Glyphicon, Col, Row } from 'react-bootstrap'; | |
import BigCalendarCSS from 'react-big-calendar/lib/css/react-big-calendar.css'; | |
import BigCalendar from 'react-big-calendar'; | |
import Moment from 'moment'; | |
import Events from 'Events.jsx'; // https://github.com/jquense/react-big-calendar/blob/master/examples/events.js | |
export default class Planner extends React.Component { | |
constructor(props, context) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export default class If extends React.Component { | |
constructor(props) | |
{ | |
super(props); | |
this.state = {condition: this.props.condition}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- In my JEE project I use REACT with Babel and Webpack and I must build the javascript files before prepare the WAR. | |
I have also configure webpack.config.js to build in a folder under my web application, e.g.: | |
var DIST_PATH = path.resolve(ROOT_PATH, '../src/main/java/webapp/js/react'); | |
To setup REACT inside my project I used https://github.com/gesposito/bare-webpack | |
--> | |
<project> | |
<build> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Starting from two route, this algorithm, verify if they are the same direction. | |
* The computeHeading function is defined in https://gist.github.com/jesty/7b2a8e31d56c13a6adff | |
*/ | |
var sameDirection = function(startA, endA, startB, endB){ | |
var headingA = computeHeading(startA, endA); | |
var headingA = computeHeading(startB, endB); | |
return Math.abs(headingA - headingA) < 45 | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* A heading is defined in degrees from true north, where headings are measured clockwise from true north (0 degrees). | |
* The parameter for this function are two array that identifies a geo point with latitude at position 0 and longitude | |
* at position 1. | |
* This function is similar to https://developers.google.com/maps/documentation/javascript/geometry. I developed because | |
* I need it on Meteor server side. | |
* The result is a value between -180 and 180. | |
*/ | |
var computeHeading = function (start, end){ | |
var lat1 = start[0]*Math.PI/180; |
NewerOlder