Skip to content

Instantly share code, notes, and snippets.

View gizemabali's full-sized avatar

Gizem Abalı gizemabali

  • Galaksiya Information Technologies
  • İzmir, Turkey
View GitHub Profile
@gizemabali
gizemabali / install ubuntu-desktop
Created May 3, 2019 20:18
if you accidentally destroyed ubuntu-desktop
# install ubuntu-desktop
sudo apt-get install ubuntu-desktop
@gizemabali
gizemabali / atom
Last active December 5, 2019 11:19
Prepare Atom for intelligent Python development
# set python3 as a default python on Ubuntu
# type
sudo gedit .bash_aliases
# then write the following to file
alias python=python3
or
alias python='/usr/bin/python3'
# close current terminal and open new one
@gizemabali
gizemabali / docker.sh
Created April 5, 2019 13:45
Docker commands
## inspect container
docker container inspect <container_name>
// ...
// create client
ElasticsearchClient client = new ElasticsearchClient();
String startDateStr = "2018-10-01T00:00:00.000Z";
String endDateStr = "2019-03-15T00:00:00.000Z";
QueryBuilder query = QueryBuilders.matchQuery(<key>, <Id>);
SearchRequestBuilder searchBuilder = client.prepareSearch();
@gizemabali
gizemabali / JAVA - read from a tar.gz file
Last active March 14, 2019 11:15
JAVA - read from a tar.gz file
// File consists of json objects
FileInputStream inputStream = null;
Scanner sc = null;
try {
inputStream = new FileInputStream(file_path);
sc = new Scanner(inputStream, "UTF-8");
while (sc.hasNextLine()) {
String line = sc.nextLine();
JsonObject json = new JsonParser().parse(line).getAsJsonObject();
//...
# run script on the background
nohup script.sh &
# run script on the background and logs to a file
nohup script.sh > filename &
>> list indices
curl -X GET "localhost:9200/_cat/indices?v"
>> show elasticsearch health
curl -s -X GET 'http://localhost:9200/_cluster/health/'
>> delete index
curl -XDELETE http://localhost:9200/index_name/
>> ask document count
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
String strDate = "2019-04-01T00:00";
// create format
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
@gizemabali
gizemabali / elasticsearch_sorted_data_selector.py
Last active March 22, 2019 14:15
extract elasticsearch data in ascending order in Python
from elasticsearch import Elasticsearch
es = Elasticsearch([{'host': "localhost", 'port': 9200}])
query = {
"sort": [
{"timestamp": {"order": "asc"}},
{"_score": {"order": "asc"}}
],
"query": {"bool": {"must": [{"match": {"id": id}},
@gizemabali
gizemabali / elasticsearch_helpers_scan.py
Last active July 11, 2018 08:33
elasticsearch helpers.scan
from elasticsearch import Elasticsearch
from elasticsearch import helpers
start_time = "Some Date"
end_time = "Some Date"
parameter = ""
query = {"query": {"bool":
{"must": [
{"match": {"parameter": parameter}},
{"range": {"timestamp": {"gte": start_time, "lte": end_time}}}