Skip to content

Instantly share code, notes, and snippets.

View sandromello's full-sized avatar

Sandro Mello sandromello

View GitHub Profile
@sandromello
sandromello / Run output
Created May 7, 2012 20:34 — forked from nickanderson/Run output
How to override bundle values with passed in paramaters
cf-agent -KIf ./paramaterized_bundle_override_defaults.cf
R: mycustomvalue <- this one was my value
R: ubuntuvalue2 <- I didnt override this one
bundle edit_line set_variable_values2(file,v)
#
# Another implementation of set_variable_values.
# The input and output should be exactly the same (except the file name),
# but in some Cfengine versions there are bugs,
# so this bundle can be used as a workaround.
#
{
vars:
@sandromello
sandromello / C implementation
Created September 21, 2012 22:31
MD5 and TripleDES - C# and Python implementation
using System.Security.Cryptography;
class Program
{
static void Main(string[] args)
{
var privatekey = "RN4nog0661VvjzphNg48372t747365mNfSxirueSDYstqsqeQn?=";
var skey = "e99308c2e3373fb041775a0c813f397d";
var c = new Program();
var encrypted = c.crypto(skey, privatekey, "encrypt");
@sandromello
sandromello / Decode base64
Created September 25, 2012 16:43
Decode base64 string python
import base64
# Picture a scenario where you need to retrieve a base64 string and decrypt with a privatekey
base64str = 'E6ne2WavwjIBh3wmUtc1xQRhW9eSK4T5fNkP+GSpaUboKqiI0degfQ=='
decodedstr = base64.b64decode(base64str)
# Now you can decrypt it
decrypted = unpad(cipher.decrypt(decodestr))
@sandromello
sandromello / Windows Debug WCF
Created September 25, 2012 21:13
Log, Trace - C#
<configuration>
<system.serviceModel>
<diagnostics>
<!-- Enable Message Logging here. -->
<!-- log all messages received or sent at the transport or service model levels >
<messageLogging logEntireMessage="true"
maxMessagesToLog="300"
logMessagesAtServiceLevel="true"
logMalformedMessages="true"
logMessagesAtTransportLevel="true" />
@sandromello
sandromello / debug
Created October 18, 2012 15:09
Debugger
import logging
LOGGING_LEVELS = {'critical': logging.CRITICAL,
'error': logging.ERROR,
'warning': logging.WARNING,
'info': logging.INFO,
'debug': logging.DEBUG}
class Debug(object):
def __init__(self, caller, debugfile='pleskydebug.log', type='default', debug='False'):
@sandromello
sandromello / dr.md
Last active August 29, 2015 13:57
Disaster Recover Zimbra - Contas/Configurações

Preparando o novo servidor

Antes de começar, certifique-se que o novo servidor está configurado com todas os parâmetros do servidor antigo como hostname, domínio, e senhas.

  • Bloqueie qualquer acesso externo ao servidor pelo seu firewall. Se possível, faça um bloqueio das portas externas para evitar qualquer problema do servidor tentar acessar um endereço externo, caso não seja uma instalação multiserver.
  • O /etc/hosts deve estar configurado corretamente, pois ele utilizará as entradas para se conectar no ldap;

Instalando o novo servidor

  • Copie o arquivo de licença para um diretório qualquer;
  • Rode o ./install.sh e siga os passos do instalador;
@sandromello
sandromello / zimbra_soap_change_password.py
Created May 7, 2014 14:57
Change Password Example using Soap Zimbra API
import requests, sys
# XML para obter o token para realizar as chamadas na API
get_token = '<?xml version="1.0" ?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header><context xmlns="urn:zimbra"><format type="xml"/></context></soap:Header><soap:Body><AuthRequest xmlns="urn:zimbraAdmin"><account by="name">admin@domain.tld</account><password>adminpassword</password></AuthRequest></soap:Body></soap:Envelope>'
# Header da requisicao
req_headers = { 'Content-Type': 'application/soap+xml' }
server = 'https://yourserver:7071/service/admin/soap'
# server: endereco da requisicao; data: dados do corp da requisicao "body content"; header: os headers da requisicao; verify: desabilita checagem de certificados, https urls
@sandromello
sandromello / LocamailHttpRequest.cs
Last active August 29, 2015 14:01
Example of http request C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Collections;
namespace MailApiModule {
public static class LocamailHttpRequest {
public static LocamailHttpResponse DoRequest(string url, Method method, object serializedData) {
@sandromello
sandromello / Zimbra Token Soap API
Last active January 17, 2022 06:33
Get Zimbra Token Soap API Example in C#
// Tested with version 8.0.6
// Read more at http://wiki.zimbra.com/wiki/SOAP_API_Reference_Material_Beginning_with_ZCS_8.0#ZCS_8.0.6
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using System.Security.Cryptography.X509Certificates;