Skip to content

Instantly share code, notes, and snippets.

@hlassiege
hlassiege / gist:5383739
Last active December 16, 2015 05:19
nGram test
curl -X DELETE localhost:9200/test
curl -X PUT localhost:9200/test -d '
{
"settings" : {
"index" : {
"analysis" : {
"analyzer" : {
"myanalyzer" : {
"type" : "custom",
"tokenizer" : "lowercase",
@hlassiege
hlassiege / Blob.java
Created November 20, 2013 14:59
Store image in database instead of disk with Play Framework
package database;
import java.io.*;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.UUID;
import org.apache.commons.io.IOUtils;
@hlassiege
hlassiege / gist:179866de70c3d8d992ab
Created June 1, 2014 16:55
Nginx configuration for kibana
server {
listen 80;
server_name A.com;
root /var/www/kibana;
# Set image format types to expire in a very long time
location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ {
access_log off;
expires max;
}
public class HopSearchEnabledCondition implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
PropertyResolver resolver = conditionContext.getEnvironment();
// renvoie toujours null, les propriétés ne sont jamais résolus
return "true".equalsIgnoreCase(resolver.getProperty("hopsearch.enabled"));
}
}
package com.hopwork.hopsearch;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableAutoConfiguration
@ComponentScan(value = {"com.hopwork", "com.lateralthoughts"})
@hlassiege
hlassiege / analytics.yml
Last active August 29, 2015 14:10
Deployment file(s)
- hosts: analytics
sudo: true
vars_files:
- ../target/classes/version.yml
tasks:
- name: Ensure hopwork log folder exist
file: path=/var/log/hopwork/analytics/ state=directory group=www-data owner=www-data
- name: Ensure hopwork folder exist
@hlassiege
hlassiege / sitemap.xml
Created June 6, 2017 07:53
sitemap alternates
<link rel="alternate" href="http://www.hopwork.fr" hreflang="fr-fr"/>
<link rel="alternate" href="http://fr.hopwork.ca" hreflang="fr-ca"/>
<link rel="alternate" href="http://fr.hopwork.com" hreflang="fr"/>
@hlassiege
hlassiege / csharputf8url.txt
Last active May 3, 2018 08:56
unicode python 2.x
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword; CharSet=UTF8;
@hlassiege
hlassiege / csharputf8url.txt
Created May 3, 2018 09:26
csharputf8url.txt
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword; CharSet=UTF8;
@hlassiege
hlassiege / format.php
Created May 3, 2018 09:27
format.php
$number = 1234.56;
// Notation anglaise (par défaut)
$english_format_number = number_format($number);
// 1,235 Notation française
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56