Skip to content

Instantly share code, notes, and snippets.

@siffash
siffash / aws-elasticsearch.ts
Last active September 5, 2020 19:44
Javascript function for using Elasticsearch in AWS
/**
The following environment variables have to be set:
AWS_ES_REGION
AWS_ES_DOMAIN
AWS_ES_INDEX
AWS_ES_ACCESS_KEY_ID
AWS_ES_SECRET_ACCESS_KEY
**/
require('dotenv').config();
@siffash
siffash / mysql-to-elasticsearch
Created January 29, 2020 09:28
Migrate data from MySQL to Elasticsearch using Logstash
sudo logstash -e '
input {
jdbc {
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://domain.com:3306/database?autoReconnect=true&useSSL=false&useCursorFetch=true"
jdbc_user => "admin"
jdbc_password => "password"
jdbc_fetch_size => 1000
statement => "SELECT * FROM everything"
use_column_value => true
@siffash
siffash / extract-languages-from-osm-bz2.php
Last active February 19, 2018 20:52
Extract all unique languages from OSM .bz2 files + all unique prefixes & suffixes
<?
/*****************
*** README ***
Prerequisites:
- PHP / Apache x64
- the following PHP extensions installed & enabled: intl, bz2
Caveats:
@siffash
siffash / extract-languages-from-osm-xml.php
Last active February 17, 2018 00:43
Extract all unique languages from OSM XML file + all unique prefixes & suffixes
<?
ini_set('display_errors', '0');
ini_set('memory_limit', '-1');
ini_set('max_execution_time', 0);
set_time_limit(0);
// FILE
$xml_file = 'planet-latest.osm';
echo 'Opening the file ' . $xml_file . '... ';
@siffash
siffash / icu-install.sh
Last active December 6, 2023 13:30 — forked from aminin/icu-install.sh
Install ICU from source and build php-intl with the specific version of ICU
#!/usr/bin/env bash
if [[ -x $(which php) ]]; then
PHP_ICU_VERSION=$(php -r 'echo defined("INTL_ICU_VERSION") ? INTL_ICU_VERSION : "none";')
echo "PHP ICU version: $PHP_ICU_VERSION"
else
echo 'WARNING: PHP not installed'
PHP_ICU_VERSION=none
fi