Skip to content

Instantly share code, notes, and snippets.

View eliasah's full-sized avatar

Elie A. eliasah

View GitHub Profile
@eliasah
eliasah / es.sh
Last active August 29, 2015 14:00
Elasticsearch installation script on Ubuntu 14.04
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
# wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.0.deb
# sudo dpkg -i elasticsearch-1.1.0.deb
@eliasah
eliasah / commands.sh
Created April 29, 2014 08:01 — forked from tralston/commands.sh
Find the MD5 sum of the current directory
# Find the MD5 sum of the current directory
find . -type f | grep -v "^./.git" | xargs md5 | md5
@eliasah
eliasah / install-hadoop.sh
Last active August 29, 2015 14:00
This script will install Hadoop Packages like Hive, Pig, Sqoop
#!/bin/bash
if [ -e hadoop-2.4.0-src.tar.gz ]; then
echo "Skipping Apache Hadoop 2.4 download"
else
echo "Downloading Apache Hadoop 2.4"
wget "http://apache.crihan.fr/dist/hadoop/common/current/hadoop-2.4.0-src.tar.gz"
tar xzvf hadoop-2.4.0-src.tar.gz
cd hadoop-*
mvn package -Pdist,native -Dskiptests -Dtar
@eliasah
eliasah / fr.sh
Created May 21, 2014 12:15 — forked from dadoonet/fr.sh
#!/bin/bash
ES='http://localhost:9200'
ESIDX='test3'
ESTYPE='test'
curl -XDELETE $ES/$ESIDX
curl -XPUT $ES/$ESIDX/ -d '{
"settings" : {
@eliasah
eliasah / install_scala_sbt.sh
Last active August 29, 2015 14:02 — forked from visenger/install_scala_sbt.sh
Install Scala 2.10.3 with SBT 0.13 on Ubuntu 12.04
#!/bin/sh
# This script installs Scala 2.10.3 with SBT 0.13 on Ubuntu 12.04
wget http://www.scala-lang.org/files/archive/scala-2.10.3.tgz
tar zxf scala-2.10.3.tgz sudo mv scala-2.10.3 /usr/local/share/scala
sudo ln -s /usr/local/share/scala/bin/scala /usr/bin/scala
sudo ln -s /usr/local/share/scala/bin/scalac /usr/bin/scalac
sudo ln -s /usr/local/share/scala/bin/fsc /usr/bin/fsc
sudo ln -s /usr/local/share/scala/bin/scaladoc /usr/bin/scaladoc
@eliasah
eliasah / run.sh
Last active April 4, 2023 11:39
[elasticsearch] Ngram Tokenizer Test
#!/bin/bash
# This script demonstrates the usage of Elasticsearch's Ngram Tokenizer
curl -XDELETE localhost:9200/test?pretty=true
curl -XPUT localhost:9200/test?pretty=true -d '{
"settings":{
"analysis":{
"analyzer":{
"my_ngram_analyzer":{
"tokenizer":"my_ngram_tokenizer"
@eliasah
eliasah / knn.sh
Last active July 7, 2016 21:33
[elasticsearch] compute K-nearest neighbor for training a classifier purposes
##########################################################################################
# use case: training a classifier
#
# Many systems classify documents by assigning “tag” or “category” fields. Classifying
# documents can be a tedious manual process and so in this example we will train a classifier
# to automatically spot keywords in new documents that suggest a suitable category.
curl -XGET "http://localhost:9200/products_fr/_search" -d'
{
"query": {
wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb
sudo dpkg -i puppetlabs-release-precise.deb
sudo apt-get update
Kibana 3 against ElasticSearch 1.4 throws an **Connection Failed** screen. The error text says to set `http.cors.allow-origin`, but it misses out the important `http.cors.enabled: true`
Working config:
$ grep cors elasticsearch-1.4.0.Beta1/config/elasticsearch.yml
http.cors.allow-origin: "/.*/"
http.cors.enabled: true
* [Ref](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-http.html)
* [Ref](http://elasticsearch-users.115913.n3.nabble.com/Kibana-upgrade-trouble-nor-4-0BETA1-neither-3-11-work-now-td4064625.html)
// derived from http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
function map() {
emit(1, // Or put a GROUP BY key here
{sum: this.value, // the field you want stats for
min: this.value,
max: this.value,
count:1,
diff: 0, // M2,n: sum((val-mean)^2)
});