Skip to content

Instantly share code, notes, and snippets.

View macielportugal's full-sized avatar

Maciel Portugal macielportugal

View GitHub Profile
@macielportugal
macielportugal / actions.py
Last active June 1, 2018 19:33
Action to export to csv in Django 2.0
# Action Export CSV to DJANGO 2.0
import csv
from django.http import HttpResponse
def export_csv(modeladmin, request, queryset):
response = HttpResponse(content_type="text/csv")
response['Content-Disposition'] = 'attachment; filename="export.csv"'
writer = csv.writer(response)
@macielportugal
macielportugal / dangolcsvdownloadmanitellyouwhat.js
Created September 11, 2018 12:34 — forked from wholypantalones/dangolcsvdownloadmanitellyouwhat.js
Force download of csv response from ajax request
$.ajax({
url: "path/to/csvData",
type: "GET",
dataType: "text",
success: function (data) {
csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(data);
$("#exportsags").attr({
"href": csvData,
"download": "sag_data.csv"
@macielportugal
macielportugal / alert.py
Created November 16, 2018 20:28
Alert if the site goes down by sending an email or slack.
#!/usr/bin/env python3.6
# coding=utf-8
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib
import urllib.request
import subprocess
import shlex
@macielportugal
macielportugal / AsteriskBlockIP.sh
Last active October 1, 2019 02:56
Script para bloquear ips que tenta logar no servidor Asterisk com senha inválida
#!/bin/bash
logFile="/var/log/asterisk/messages"
debugFile="/var/log/asterisk/ips-bloqueados.log"
attempts=3
whitelist="127.0.0.1"
name=`basename $0`
checkIsScriptRunning=$(ps | grep $name | grep -v grep | wc -l)
if [ $checkIsScriptRunning -ge 3 ]; then
import unittest
import re
class CEP:
MESSAGE_NUMBER_OUT_OF_RANGE = "Number out of range [100000-999999]"
MESSAGE_INVALID_NUMBER = "Invalid number"
def valid(self, number):
self.messages = []
@macielportugal
macielportugal / Cisco 7912 Series
Last active October 28, 2022 13:29
Como resolver o problema das luzes sempre acesa no telefone da Cisco 7912
Meu telefone Cisco 7912 estava com a tela em branco e as luzes sempre acesas, o telefone não realiza o boot.
Eu resolvi este problema subindo um servidor DHCP Server + tftp usando dnsmasq no arch linux
Utilizando estes links como referencia
https://wiki.archlinux.org/title/Dnsmasq_(Portugu%C3%AAs)
https://bbs.archlinux.org/viewtopic.php?id=271778
https://itblog.su/downloads/cp7912r.zup
https://github.com/staskobzar/cisco_prov/blob/master/sip/Readme7912.txt
https://github.com/staskobzar/cisco_prov/tree/master/sip
@macielportugal
macielportugal / whatsapp-errors.json
Created October 23, 2023 20:09
Mensagem de erros do Whatsapp
{
"400": {
"title": "Erro de download de m\u00eddia",
"description": "Falha ao baixar a m\u00eddia do remetente."
},
"402": {
"title": "Elegibilidade da empresa (problema de pagamento)",
"description": "Verifique a configura\u00e7\u00e3o de pagamento no Gerenciador do WhatsApp e tente novamente."
},
"408": {