Skip to content

Instantly share code, notes, and snippets.

View jccorrea's full-sized avatar

Julio Cesar Correa jccorrea

  • Sao Paulo,Brazil
View GitHub Profile
@jccorrea
jccorrea / some MacOs setup commands
Created September 20, 2015 16:08
change MacOs hostname
# This is your fully qualified hostname, for example myMac.domain.com
sudo scutil --set HostName <new host name>
#Type the following command to change the Bonjour hostname of your Mac:
#This is the name usable on the local network, for example myMac.local.
sudo scutil --set LocalHostName <new host name>
#Optional: If you also want to change the computer name, type the following command:
#This is the user-friendly computer name you see in Finder, for example myMac.
sudo scutil --set ComputerName <new name>
#Flush the DNS cache by typing:
dscacheutil -flushcache
@jccorrea
jccorrea / conver_ec2_pem_to_ssh.sh
Last active September 21, 2015 23:10
convert .pem file to ssh key
# copy output to ~/.ssh/authorized_keys
ssh-keygen -y -f yourprivatekey.pem
@jccorrea
jccorrea / ec2 amazon via ssh
Last active September 22, 2015 02:42
amazon - .pem file and ssh key
ssh -i file.pem user@ec2instanceamazon
piano02:Downloads julio$ scp -i /Users/julio/Downloads/ec2hadoopcluster.pem /Users/julio/Downloads/ec2hadoopcluster.pem ubuntu@ec2-52-89-99-43.us-west-2.compute.amazonaws.com:/home/ubuntu
@jccorrea
jccorrea / explorando_marte.md
Created August 17, 2016 02:57 — forked from nirev/explorando_marte.md
Teste de Programação - Backend - XERPA

Teste de Programação - Backend - XERPA

Olá! Como parte do processo de seleção da Xerpa, gostaríamos que você fizesse uma pequena tarefa. Esperamos que ela seja feita preferencialmente em uma das nossas linguagens principais: Elixir, Erlang ou Clojure.

A ideia é olhar como é seu estilo de programação e quais decisões você toma ao resolver um problema. Para isso, crie um projeto no seu Github para podermos acompanhar a árvore de commits!

Sinta-se à vontade para criar em cima do problema abaixo.

4. Hive Rank by Volume only
SELECT
s.RepName, s.Territory, V.volume,
rank() over (ORDER BY V.volume DESC) as rank
FROM
SalesRep s
JOIN
( SELECT
SalesRepId, SUM(amount) as Volume
--com substr de data
select dt_referencia , weekofyear(regexp_replace(substr(dt_referencia,1,10),'/','-') )from gvt.gvt_lis_stg limit 10;
-- sem substr
select dt_referencia , weekofyear(regexp_replace(dt_referencia,'/','-') )from gvt.gvt_lis_stg limit 10;
# dummy
create table dual as select 1 as X ;
@jccorrea
jccorrea / gist:08f9a2928af6af8483df9dda12e9b447
Created March 25, 2017 01:02
append header to text file . by Dennis Williamson
echo 'task goes here' | cat - todo.txt > temp && mv temp todo.txt
or
sed -i '1s/^/task goes here\n/' todo.txt
or
sed -i '1itask goes here' todo.txt
@jccorrea
jccorrea / write_single_csv.py
Created March 25, 2017 01:05
Spark - write single CSV file by Richard Garris
df.coalesce(1).write.format("com.databricks.spark.cvs").save("...path...")
#copy this file to local machine
dbutils.fs.cp("...path...", "..path.. ..csv")
@jccorrea
jccorrea / export_variables_from_file.sh
Created March 29, 2017 18:22
Unix/Linux - export variables from file
set -a
. tmp.txt
set +a
# credits to Stéphane Chazelas