Skip to content

Instantly share code, notes, and snippets.

View IuryAlves's full-sized avatar

Iury Alves de Souza IuryAlves

View GitHub Profile
prompt_kubectl() {
currentCluster=$(kubectx -c 2>/dev/null)
currentNamespace=$(kubens -c 2>/dev/null)
if test -n "$currentCluster"; then
prompt_segment yellow black "kubernetes($currentCluster:$currentNamespace)"
fi
}
@IuryAlves
IuryAlves / test.go
Last active April 8, 2022 12:05
test.shell
go run ./main.go
Running ....
Active cluster: europe-west1-b/gke-eu
Grid emissions percentage: 48
Active cluster: europe-west1-b/gke-eu
Grid emissions percentage: 48
Active cluster: europe-west1-b/gke-us
Grid emissions percentage: 40
Active cluster: europe-west1-b/gke-us
Grid emissions percentage: 40
# coding: utf-8
import requests
from multiprocessing import Process, Pipe
def downloader(url, chunk_size, conn):
downloaded_parts = 0
with open('download', 'wb') as fp:
# coding: utf-8
import requests
chunk_size = 1024 * 1024 # 1mb
download_url = 'http://speedtest.ftp.otenet.gr/files/test10Mb.db'
downloaded_parts = 0
with open('download', 'wb') as fp:
response = requests.get(download_url, stream=True)
from pprint import pprint
from datetime import datetime
from project_files import *
from git_hub_scrapper import *
from file import *
DOMAIN = 'https://github.com'
def main():
print('[INICIO.{_date:%Y/%m/%d %H:%M:%S}]'.format(_date=datetime.now()))
def get_depth(self):
parent = self.parent
depth = 0
while parent is not None:
parent = parent.parent
depth += 1
return depth
# coloca isso na classe Link
# coding: utf-8
"""
pip install requests beautifulsoup4
"""
import requests
from bs4 import BeautifulSoup
@IuryAlves
IuryAlves / pre-commit
Created August 31, 2017 14:41
git pre-commit hook
#!/usr/bin/env python
# Original at http://tech.yipit.com/2011/11/16/183772396/
# Insert this into .git/hooks/pre-commit
import re
import subprocess
import sys
modified = re.compile('^(?:M|A)(\s+)(?P<name>.*)')
@IuryAlves
IuryAlves / django_test_manage.py
Created July 25, 2017 17:57
Run Django tests without migrations
#!/usr/bin/env python
import os
import sys
from django.core.management import ManagementUtility
from django_test_runner import is_nosetest
from pycharm_run_utils import import_system_module
from teamcity import teamcity_presence_env_var
@IuryAlves
IuryAlves / compress_s3_images.py
Created February 22, 2017 20:11 — forked from rigoneri/compress_s3_images.py
Simple python code to compress (jpeg/png) images uploaded to S3. In this use case I want to compress down all images that are over 500 KB down to 80% quality which brings the images down to about 100KB. Feel free to muck with the values.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from boto.s3.connection import S3Connection
from cStringIO import StringIO
from PIL import Image as pil
AWS_KEY = '[AWS KEY HERE]'