Skip to content

Instantly share code, notes, and snippets.

View sandromello's full-sized avatar

Sandro Mello sandromello

View GitHub Profile
@sandromello
sandromello / auth.py
Created July 4, 2016 12:20
Autenticação Loja
import urlparse
import requests
AUTH_URL = 'https://{}/public/login?integrandose=true'.format('app.lojaintegrada-staging.com.br')
form_data = {
'email': STORE_USER,
'senha': STORE_USER_PASSWD
}
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
r = requests.post(AUTH_URL, data=form_data, headers=headers, allow_redirects=False, verify=False)
@sandromello
sandromello / aws-ip.sh
Created April 6, 2016 12:43
aws-cli get instances ips
#!/bin/bash
searchString=$1
IpSearchType=PublicIpAddress
if [ "$1" = "private" ]; then
IpSearchType=PrivateIpAddress
searchString=$2
else
IpSearchType=PublicIpAddress
fi
swagger: "2.0"
info:
description: |
Koli fucking box.
[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.
For this sample, you can use the api key `special-key` to test the authorization filters
version: "1.0.0"
title: Koli API
@sandromello
sandromello / themis-policy.py
Last active January 12, 2016 20:10
Example using themis-core classes
# Considerando que a máquina possua o pacote themis-core instalado é possível acessar os dados
>>> from themis.marshalredis import MarshalRedis
>>> from themis.policy import Policy
>>> p = Policy(MarshalRedis('redis01.domain.tld'))
>>> print json.dumps(pdata.as_dict, indent=2)
{
"enable": true,
"jailaction": "block",
"actionheaders": {},
"policy_name": "xxxxxxxx",
@sandromello
sandromello / dr-am.md
Created September 27, 2015 19:19
DR - AM

Disaster Recovery

Como solução de Disaster Recovery optamos pela recuperação do ambiente direto na nuvem em um provedor de IaaS. Como provedor escolhemos a empresa AWS que atualmente possui uma gama de serviços que atende toda nossa demanda de infra-estrutura. Abaixo segue o desenho da solução de Disaster Recovery para nosso ambiente:

1. Nossas aplicações de crédito consistem em servidores de aplicação e o acesso direto aos dados através de volumes agregados aos servidores, através desse ambiente controlamos todos os ativos de TI para fornecer nossa solução. 2. Com o serviço Storage Gateway que é um serviço que se conecta com um aplicativo on-premise fornecendo uma solução de Storage baseada em cloud. Ele realiza uploads de forma segura dos dados para a nuvem da AWS. 3. Os dados da aplicação, snapshots e AMI's (imagens de sistema operacional) ficam guardados no Amazon S3, um storage durável e de baixo custo. As AMI's são imagens customizadas de sistema

@sandromello
sandromello / create_site.ps1
Created September 17, 2015 21:04
Create Site OneDrive - Office365
$loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
$loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.UserProfiles")
#Must be SharePoint Administrator URL
$webUrl = "https://domain-admin.sharepoint.com"
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
$web = $ctx.Web
$username = "[email protected]"
@sandromello
sandromello / set-plan.ps1
Created August 31, 2015 20:45
Bulk set license to unlicensed users
# Usage: set-plan.ps1 client:licenseplan c:/users.txt
# It will loop for all unlicensed users and check if exists in c:/users.txt file
# In case of a match, it will set the license of the users matched.
# Note: Usage location defaults to BR
param([String]$licensePlan="", [String]$accountsPath="");
import-module MSOnline;
if ([String]::IsNullOrEmpty($licensePlan) -Or [String]::IsNullOrEmpty($accountsPath)){
Write-Host "Empty licensePlan or accountsPath parameter! Exiting...";
@sandromello
sandromello / pdns.py
Created August 25, 2015 14:01
Power DNS API implementation
import unittest, sys, requests, json, uuid
from datetime import datetime
#url = 'http://192.168.99.100/servers/localhost/zones/'
#url = 'http://192.168.99.100/servers/localhost/zones/example.local.'
#url = 'http://192.168.99.100/servers'
SERVER = 'pdns.tempo.com.br:8080'
HEADERS = {'X-API-Key' :'changeme'}
@sandromello
sandromello / sec.py
Created July 10, 2015 00:29
Secret Gist
from redis import StrictRedis
from redis.client import BasePipeline
from itertools import izip
from ast import literal_eval
import marshal, uuid
MARSHAL_TYPES = [list, dict, bool]
MAILDATA_CUSTOM_CALLBACK = {
'customerid' : str,
'domainid' : str,
@sandromello
sandromello / antispam.py
Last active August 29, 2015 14:23
teste antispam
import smtplib, sys
from email.mime.text import MIMEText
from traceback import format_exc
def sendMail(host, sender, rcpts):
msg = MIMEText("""XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X""")
msg['Subject'] = "XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X"
msg['From'] = sender
try:
serv = smtplib.SMTP('mxhero01.abgf.gov.br', 25)