- 💄 cosmetic changes without functional changes
- ♻️ refactoring
- 🚀 finalizing new version / release
- 📚 documentation
- 🙏 experimental code (without test)
- 🚧 work in progress
- ✨ new feature
- 🗑️ deleting unused code
- 🔈 added logging
- 🔇 reduced logging
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
List<Map<String, Object>> listOfMaps = Lists.newArrayList(); | |
listOfMaps.add(ImmutableMap.of("a",1)); | |
listOfMaps.add(ImmutableMap.of("b",1)); | |
listOfMaps.add(ImmutableMap.of("b",1)); | |
List<String> allKeys = listOfMaps.stream() | |
.flatMap(map -> map.keySet().stream()) | |
.collect(Collectors.toList()); | |
assertThat(allKeys, Matchers.containsInAnyOrder("a","b","b")); |
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
List<Map<String, Object>> listOfMaps = Lists.newArrayList(); | |
listOfMaps.add(ImmutableMap.of("a",1.0)); | |
listOfMaps.add(ImmutableMap.of("b",1.0)); | |
listOfMaps.add(ImmutableMap.of("b",2.0)); | |
List<Object> allValues = listOfMaps.stream() | |
.flatMap(map -> map.values().stream()) | |
.collect(Collectors.toList()); | |
assertThat(allValues, Matchers.containsInAnyOrder(1.0,1.0,2.0)); |
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
POST _reindex | |
{ | |
"source": { | |
"index": "source_idx", | |
"type": "sourc_idx_type", | |
"query": { | |
"terms": { | |
"_id": [ | |
"the_id" | |
] |
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
# copy your cron jobs | |
crontab -l > cron.txt | |
# copy the exported config to otherHost | |
scp cron.txt otherHost:/your_directory | |
# login to otherHost | |
ssh otherHost | |
# set the cronjobs to your old config | |
crontab cron.txt |
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 cv2 # opencv | |
import numpy as np | |
font_scale = 1.5 | |
font = cv2.FONT_HERSHEY_PLAIN | |
# set the rectangle background to white | |
rectangle_bgr = (255, 255, 255) | |
# make a black image | |
img = np.zeros((500, 500)) |
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
# working version of https://bretahajek.com/2017/01/scanning-documents-photos-opencv/ | |
import cv2 | |
import numpy as np | |
def resize(img, height=800): | |
""" Resize image to given height """ | |
ratio = height / img.shape[0] | |
return cv2.resize(img, (int(ratio * img.shape[1]), height)) |
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
// create the script query | |
ScriptQueryBuilder scriptQuery = QueryBuilders.scriptQuery(new Script("params._source.your_field.size() > 1")); | |
// add the query in a boolean term to enforce the filter | |
client.prepareSearch(indices).setQuery(QueryBuilders.boolQuery().must(scriptQuery)).get(); | |
// the response will only contain documents whith more than one item in the field "your_field" | |
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
def rotateWithShapeFit(image, rotations=None): | |
""" | |
Rotates the given image by 90, 180 or 270 degrees, keeping the original image shape. | |
The original shape is kept by adding black borders both at the top and bottom or the left and the right of the | |
rotated image. | |
Args: | |
image: the image to rotate. | |
rotations: the number of rotations by 90 degrees. 1 will rotate the image by 90°, 2 by 180° and 3 by 270°. |
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 argparse | |
import os | |
import fasttext | |
from sklearn.base import BaseEstimator | |
from sklearn.metrics import f1_score | |
from sklearn.model_selection import cross_val_score, StratifiedKFold | |
def read_data(data_dir): |
OlderNewer