Skip to content

Instantly share code, notes, and snippets.

View wesleyit's full-sized avatar

Wesley Rodrigues wesleyit

View GitHub Profile
@wesleyit
wesleyit / play_lumberjack.py
Last active February 26, 2019 13:20
Play lumberjack in Telegram using Python
# pip install pyscreenshot pyuserinput
import pyscreenshot
import pykeyboard
import time
X1 = 780
X2 = 785
Y1 = 410
Y2 = 420
@wesleyit
wesleyit / runner.py
Created October 25, 2018 14:11
Run scheduled tasks in Python :D
"""
runner.py - This is a cron-like executor.
You can run Python files in scheduled times.
"""
import schedule
import time
# Files to run (ordered)
files_to_run = ['some_file_1.py', 'another_file_2.py']
@wesleyit
wesleyit / free_memory.sh
Created October 16, 2018 17:43
This script can free memory by calling some kernel parameters via /proc/sys filesystem.
#!/bin/bash
if [ "$(whoami)" != "root" ]
then
echo "Execute este comando com sudo ou como root."
exit 1
fi
clear
echo '------------------------------------------------------------'
@wesleyit
wesleyit / keras_example.py
Created September 21, 2018 14:36
Python 3 + Keras: Simple neural network
# Create first network with Keras
from keras.models import Sequential
from keras.layers import Dense
import numpy as np
# Define your X and y here
X = np.array([[1, 0], [1, 1], [0, 1], [0, 0]])
y = np.array([1, 1, 1, 0])
# Create model
@wesleyit
wesleyit / offline_setup.sh
Created August 31, 2018 21:38
Control/Block the internet access of specific programs and commands
#!/bin/bash
# Com este script você cria uma forma de executar comandos
# que não terão acesso à rede externa e Internet.
# Por exemplo, se você quiser forçar o Spotify a fica offline:
# offline spotify.bin
sudo groupadd offline
echo '#!/bin/bash' | sudo tee /usr/local/bin/offline
echo 'sg offline "$*"' | sudo tee -a /usr/local/bin/offline
sudo chmod a+x /usr/local/bin/offline
@wesleyit
wesleyit / pandas_sql_odbc.py
Created August 31, 2018 18:08
Pandas fetching SQL from Athena with pyODBC
import pandas as pd
import pyodbc as odbc
import os
query = 'select * from vendas'
# Trago os dados do servidor caso não exista um cache local,
# senão apenas carrego o cache
if os.path.isfile('./dados/julho_com_sala.csv'):
@wesleyit
wesleyit / get_csv_by_1000.py
Created August 13, 2018 13:20
Get a CSV file from a SQL query using batches of 1000 lines
import sys
import pyodbc as odbc
import datetime
dsn = sys.argv[1]
query_file = sys.argv[2]
csv_file = sys.argv[3]
print(f'Connecting to {dsn}')
print(f'Executing {query_file}')
@wesleyit
wesleyit / get_csv.py
Created August 13, 2018 13:19
Get a CSV file from a SQL query
import sys
import pyodbc as odbc
import datetime
dsn = sys.argv[1]
query_file = sys.argv[2]
csv_file = sys.argv[3]
print(f'Connecting to {dsn}')
print(f'Executing {query_file}')
@wesleyit
wesleyit / imc.py
Created May 20, 2018 01:30
Creating a graphical application using python and QT
import sys
import time
from PyQt5.QtWidgets import QApplication, QDialog
from PyQt5.uic import loadUi
class IMC(QDialog):
def __init__(self):
super().__init__()
loadUi('imc.ui', self)
@wesleyit
wesleyit / test_tensorflow.py
Created May 15, 2018 17:40
Test tensorflow to verify the GPU availability
from tensorflow.python.client import device_lib
def get_available_devices():
local_device_protos = device_lib.list_local_devices()
return [x.name for x in local_device_protos]
print(get_available_devices())