Skip to content

Instantly share code, notes, and snippets.

View pvsousalima's full-sized avatar
💭
(sometimes) I may be slow to respond.

Pedro Victor pvsousalima

💭
(sometimes) I may be slow to respond.
View GitHub Profile
@pvsousalima
pvsousalima / runner.sh
Created July 2, 2019 15:05
registering a runner and running
docker run --rm -v ~/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \
--non-interactive \
--executor "shell" \
--docker-image alpine:latest \
--url "https://gitlab.com/" \
--registration-token "" \
--description "docker-runner" \
--tag-list "develop" \
--run-untagged="true" \
--locked="false" \
@pvsousalima
pvsousalima / gcloud_k8s.sh
Last active October 19, 2018 15:49
Install gcloud and kubectl on a mac
curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz > /tmp/google-cloud-sdk.tar.gz
mkdir -p ~/gcloud \
&& tar -C ~/gcloud -xvf /tmp/google-cloud-sdk.tar.gz \
&& ~/gcloud/google-cloud-sdk/install.sh -q;
brew install kubernetes-cli
gcloud components install docker-credential-gcr -q
@pvsousalima
pvsousalima / gist:2a2d1ab9e72434aedb83a0a8c1de54e7
Created May 29, 2018 22:34
Kubernetes delete all evicted pods in a cluster
kubectl get po -a --all-namespaces -o json | jq '.items[] | select(.status.reason!=null) | select(.status.reason | contains("Evicted")) | "kubectl delete po \(.metadata.name) -n \(.metadata.namespace)"' | xargs -n 1 bash -c
@pvsousalima
pvsousalima / comoSerChatoNowhatsapp.js
Created October 18, 2017 13:53 — forked from callmeloureiro/comoSerChatoNoWhatsapp.js
Como fazer alguém te responder no whatsapp
var counter = 0;
var mensagens = document.getElementsByClassName("message-in");
var quantidadeMsg = mensagens.length
var i = setInterval(function(){
window.InputEvent = window.Event || window.InputEvent;
var d = new Date();
var event = new InputEvent('input', {bubbles: true});
var textbox = document.querySelector('#main > footer > div.block-compose > div.input-container > div.pluggable-input.pluggable-input-compose > div.pluggable-input-body.copyable-text.selectable-text');
@pvsousalima
pvsousalima / node.js
Created January 19, 2016 01:26
node.js getting dollar rate
app.get('/dollarRate', function(request, response) {
var from = "USD"
var to = "BRL"
var url = "http://query.yahooapis.com/v1/public/yql?q=select%20rate%2Cname%20from%20csv%20where%20url%3D'http%3A%2F%2Fdownload.finance.yahoo.com%2Fd%2Fquotes%3Fs%3DUSDBRL%253DX%26f%3Dl1n'%20and%20columns%3D'rate%2Cname'&format=json"
http.get(url, function(res){
var body = '';
@pvsousalima
pvsousalima / comic.cpp
Created January 30, 2015 20:05
Funny C++ code of a comic of tank's race where all tanks win the race
/*
This program was built under the Mac OS X Yosemite version 10.10.1
and g++ compiler described as follows:
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
It was tested, compiled and fully functional on Mac by command line.
@pvsousalima
pvsousalima / resolutions.py
Last active August 29, 2015 14:12
Google's code resolutions
'''Given a function which produces a random integer in the range 1 to 5,
write a function which produces a random integer in the range 1 to 7.'''
import random
# Produces a random integer in the range 1 to 5
def random_int15():
return random.choice(range(1,6))
# Produces a random integer in the range 1 to 7 using the previous function
@pvsousalima
pvsousalima / server_ping.py
Created November 9, 2014 23:52
Simple server to test pings
# UDPPingerServer.py
# We will need the following module to generate randomized lost packets import random
from socket import *
# Create a UDP socket
# Notice the use of SOCK_DGRAM for UDP packets
import random
serverSocket = socket(AF_INET, SOCK_DGRAM) # Assign IP address and port number to socket
serverSocket.bind(('', 12000))
@pvsousalima
pvsousalima / machine.py
Created November 6, 2014 21:29
A virtual stack machine interpreter written in python
# CSC 333 -- Homework 4 -- Stack machine interpreter
# Pedro Victor
# Time-stamp: <2014-10-21 21:04:52 shade>
# Your job is to complete the 'runvm' function. Don't change any of
# the other code. I will test your program using the 'run' function,
# which calls 'runvm' to do the heavy lifting.
#
# This code simulates a simple stack VM (virtual machine). Programs
# are written in a compact string form that is then compiled into a
set MAX_N 200
set MIN_VALUE -2147483648
set MAX_VALUE 2147483647
proc read_data {} {
# Open file in read mode
set input [open "ripoff.in" r]
# read the file content