Skip to content

Instantly share code, notes, and snippets.

View olivx's full-sized avatar

Thiago Oliveira olivx

  • Tivit
  • Sao Paulo
View GitHub Profile
# 1. Create the docker group.
$ sudo groupadd docker
# 2. Add your user to the docker group.
$ sudo usermod -aG docker $USER
# 3. Log out and log back in so that your group membership is re-evaluated.
# 4. Verify that you can run docker commands without sudo.
$ docker run hello-world
@olivx
olivx / pandas_write_xls_formating_cols.py
Created November 14, 2018 18:35
formatando colunas ao exportar um dataframe com pandas para excel
list_schedule = []
for user in sc.candidates.all():
data = dict(
email=user.email,
cpf=cpf,
phone=user_profile.phone1
)
list_schedule.append(data)
df = pd.DataFrame(list_schedule)
@olivx
olivx / upload_using_boto3.py
Last active November 16, 2018 18:18
fazendo o upload para file sytem suando o boto3 ou file system stora
import boto3
from boto.s3.connection import Bucket, Key
video_id = request.POST.get('vid_id')
video_name = video_id + "_qvga_webm.webm"
video_interview = request.FILES['video_interview']
uploaded_file_url = "https://s3.amazonaws.com/yourbubeckt/"
filename = 'pass-your-path/' + video_name
@olivx
olivx / report-runner.py
Created November 1, 2018 18:30 — forked from chris1610/report-runner.py
Pandas Pivot Table Reporting Example - pbpython.com
# -*- coding: utf-8 -*-
"""
Sample report generation script from pbpython.com
This program takes an input Excel file, reads it and turns it into a
pivot table.
The output is saved in multiple tabs in a new Excel file.
"""
@olivx
olivx / jquery_ajax_upload_download.js
Created November 1, 2018 02:25
estrutura exemplo download e upload via ajax com jquery
$.ajax({
type: 'POST',
url: "/",
data: {},
beforeSend: function(XMLHttpRequest)
{
//Upload progress
XMLHttpRequest.upload.addEventListener("progress", function(evt){
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
@olivx
olivx / vanilla_javascript_ajax.js
Created November 1, 2018 02:23
estrutura exemplo de vanilla javascript fazendo upload vai ajax
function uploadFile (file) {
return new Promise( (resolve, reject) => {
const xhr = new XMLHttpRequest()
let fd = new FormData()
fd.append('the-file', file)
xhr.open('post', '/')
xhr.onerror = reject
xhr.onload = event => {
@olivx
olivx / vanilla_javascript_click.js
Last active November 1, 2018 04:11
vanilla java script simulando cick
/**
* Simulate a click event.
* @public
* @param {Element} elem the element to simulate a click on
*/
var simulateClick = function (elem) {
// Create our event (with options)
var evt = new MouseEvent('click', {
bubbles: true,
cancelable: true,
.container {
width: 100vw;
height: 100vh;
background: #6C7A89;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center
}
@olivx
olivx / email_track.py
Created October 19, 2018 21:12
semd mail mass end track_email
# save message to DB
email_track = Message(
body=message_body,
sender=request.user,
recipient=cand.candidate,
job=obj,
uuid=uuid.uuid4()
)
_url = '{}{}?uuid={}'.format(settings.CAREER_PAGE_DOMAIN, reverse(
@olivx
olivx / random_date.py
Last active October 18, 2018 17:56
This function will return a random datetime between two datetime objects.
from random import randrange
from datetime import timedelta
from datetime import datetime
import pytz
def random_date(start, end):
"""
This function will return a random datetime between two datetime
objects.
"""