Skip to content

Instantly share code, notes, and snippets.

View joaoluiznaufel's full-sized avatar

João Luiz Castro Naufel joaoluiznaufel

  • João Luiz Castro Naufel
  • Cacoal - RO - BR
View GitHub Profile
@joaoluiznaufel
joaoluiznaufel / kubernetes - configs
Last active September 17, 2018 15:14
Kubernetes
##Get cluster info
$ kubectl cluster-info
##Get nodes
$ kubectl get nodes
##Get contexts (used for multiple clusters)
$ kubectl config get-contexts
##Change contexts
@joaoluiznaufel
joaoluiznaufel / gcloud - config
Last active August 29, 2018 12:45
gcloud commands
#get the account
gcloud config get-value account
#list your projects
gcloud projects list
#set the project
gcloud config set project <project name>
# set account to use
@joaoluiznaufel
joaoluiznaufel / gcloud - auth
Last active August 29, 2018 12:45
gcloud commands
#login at google cloud
gcloud auth login
#list all the accounts
gcloud auth list
@joaoluiznaufel
joaoluiznaufel / gcloud - compute
Last active September 6, 2018 14:23
gcloud commands
#get all the compute instances
gcloud compute instances list
#start a ssh connection
gcloud compute ssh mongo --zone us-west1-b
#using scp to send files recursive
gcloud compute scp ~/path/file <instance name>:/path/file --zone us-west1-b --recurse
#create ssh tunnel
sed -n '$=' $1
# Split a big file into multiples fiels
tail -n +2 file_name.csv | split -l 59000 - split_
for file in split_*
do
head -n 1 file_name.csv > tmp_file
cat $file >> tmp_file
mv -f tmp_file $file
done
#!/bin/bash
case "$1" in
"server1") echo "Connecting to server1"
sshpass -p 'your_passwd' ssh <user>@<ip_server>
echo "Connection closed with $1"
;;
"server2") echo "Connecting to server2"
sshpass -p 'your_passwd' ssh <user>@<ip_server>
@joaoluiznaufel
joaoluiznaufel / gsutil
Created September 17, 2018 15:16
Gsutil
#send files to buckets
gsutil rsync -d -r <folder path> gs://<name of your bucket>
#change permission bucket
gsutil acl ch -u AllUsers:R gs://yourbucket/**
@joaoluiznaufel
joaoluiznaufel / mongo cli
Created September 17, 2018 15:18
mongo cli
#insert user:
db.Client.insertOne( {
"id": "5788a5f71b2b6de0148b4567",
"name": "jonho",
"lastname": "dust"
});
#show current table
db
@joaoluiznaufel
joaoluiznaufel / scala - if expressions
Created March 4, 2019 07:17
built-in control structures
var hello = "hello"
if (!hello.isEmpty)
print "is not empty"
var myHello = if (!hello.isEmpty) "is not empty" else "is empty"