Skip to content

Instantly share code, notes, and snippets.

View igorcosta's full-sized avatar
:octocat:

Igor Costa igorcosta

:octocat:
View GitHub Profile
@igorcosta
igorcosta / billion.py
Last active March 12, 2020 00:16
Running 1 Billion func in Python3 with joblib
#pip3 install joblib first
from joblib import Parallel, delayed
import time
start_time = time.time()
def BillionFuncJob(key):
@igorcosta
igorcosta / MainActivity.java
Created July 3, 2018 04:19 — forked from mjohnsullivan/MainActivity.java
Android Wear activity that reads and displays sensor data from the device
package com.example.wear;
import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.support.wearable.view.WatchViewStub;
import android.util.Log;
@igorcosta
igorcosta / build_npm.sh
Created May 23, 2016 04:32
Auto increment version of npm and git tagging
#! /bin/bash
npm version patch
version=`git diff HEAD^..HEAD -- "$(git rev-parse --show-toplevel)"/package.json | grep '^\+.*version' | sed -s 's/[^0-9\.]//g'`
git add *;
git commit -m "Commit message"
if [ "$version" != "" ]; then
git tag -a "v$version" -m "`git log -1 --format=%s`"
echo "Created a new tag, v$version"
@igorcosta
igorcosta / gist:835152315d756377a9d297dcdad0f5ff
Created March 27, 2018 02:34 — forked from kyledrake/gist:d7457a46a03d7408da31
Creating a self-signed SSL certificate, and then verifying it on another Linux machine
# Procedure is for Ubuntu 14.04 LTS.
# Using these guides:
# http://datacenteroverlords.com/2012/03/01/creating-your-own-ssl-certificate-authority/
# https://turboflash.wordpress.com/2009/06/23/curl-adding-installing-trusting-new-self-signed-certificate/
# https://jamielinux.com/articles/2013/08/act-as-your-own-certificate-authority/
# Generate the root (GIVE IT A PASSWORD IF YOU'RE NOT AUTOMATING SIGNING!):
openssl genrsa -aes256 -out ca.key 2048
openssl req -new -x509 -days 7300 -key ca.key -sha256 -extensions v3_ca -out ca.crt
@igorcosta
igorcosta / ElasticSearch.md
Created January 6, 2017 00:44 — forked from tokhi/ElasticSearch.md
Elastic Search in simple words

Elastic Search

Elasticsearch is a real time search engine where a change to an index will be propegated to the whole cluster within a second.

An elasticsearch cluster indicated as one or more nodes, collection of nodes containing all the data, default cluster name is elasticserach.

A node is a single server and part of a cluster, node participate in searching and indexing.

Index is collection of documents equavalent to a database within a relational system, index name must be lowercase Type is represetn a class = table

@igorcosta
igorcosta / elastic_bulk_ingest.py
Created January 6, 2017 00:49 — forked from scotthaleen/elastic_bulk_ingest.py
Bulk Index json to elastic search
from pyspark import SparkContext, SparkConf
import json
import argparse
def fn_to_doc(line):
try:
doc = {}
data = json.loads(line)
doc['data'] = data
@igorcosta
igorcosta / ES-Setup
Created January 6, 2017 00:40
Elastic Search install instructions
Elastic Search Setup guide for N OS
=============
Mac Install
-------
- Download last version http://www.elasticsearch.org/download/
- Extract in /usr/local/share/elasticsearch
- cd /usr/local/share/
- sudo chown -R root:wheel elasticsearch
@igorcosta
igorcosta / es-attach-full.py
Created January 6, 2017 00:38 — forked from stevehanson/es-attach-full.py
Interactive Python script to recursively index files in directory tree to elasticSearch using the elasticsearch-mapper-attachments (https://github.com/elasticsearch/elasticsearch-mapper-attachments) plugin to index files (pdf, docx, html, etc).
import os
import sys
# constants, configure to match your environment
HOST = 'http://localhost:9200'
INDEX = 'test'
TYPE = 'attachment'
TMP_FILE_NAME = 'tmp.json'
# for supported formats, see apache tika - http://tika.apache.org/1.4/formats.html
INDEX_FILE_TYPES = ['html','pdf', 'doc', 'docx', 'xls', 'xlsx', 'xml']
function sayit(text,voice) {
var msg = new SpeechSynthesisUtterance();
msg.voice = speechSynthesis.getVoices().filter(v => v.name == voice)[0];
msg.text = text;
speechSynthesis.speak(msg);
}; sayit ('choice mate!','English UK English Male');
# 1. Add the Spotify repository signing key to be able to verify downloaded packages
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys BBEBDCB318AD50EC6865090613B00F1FD2C19886
# 2. Add the Spotify repository
echo deb http://repository.spotify.com stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list
# 3. Update list of available packages
sudo apt-get update
# 4. Install Spotify