Skip to content

Instantly share code, notes, and snippets.

View rafaelfoster's full-sized avatar

Rafael Foster rafaelfoster

View GitHub Profile
@rafaelfoster
rafaelfoster / Zimbra_nginx_upstream_ActiveSync.sh
Created May 2, 2016 20:37
Nginx configuration to create reverse proxy to Zimbra Mail Client and enable ActiveSync based on Z-PUSH.
upstream zimbramailserver {
server localhost:8443 weight=1 fail_timeout=300s; # Zimbra Mail client HTTPS port
}
server {
listen 80;
server_name mail.*;
return 301 https://$host$request_uri;
}
# http://wingloon.com/2013/05/27/how-to-setup-ssmtp-on-centos-5-9/
# http://tecadmin.net/send-email-smtp-server-linux-command-line-ssmtp/
yum install ssmtp
vim /etc/ssmtp/ssmtp.conf
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
@rafaelfoster
rafaelfoster / client.conf
Created April 13, 2016 19:47
Create a VPN Client-to-Server on a CentOS 7 with Split tunnel # Based on https://www.howtoforge.com/tutorial/how-to-install-openvpn-on-centos-7/
client
dev tun
proto udp
#Server IP and Port
remote $IP_ADDRESS 1337
resolv-retry infinite
nobind
persist-key
@rafaelfoster
rafaelfoster / lib_ldap.php
Created March 28, 2016 19:48
An PHP ldap library example
<?php
// error_reporting(E_ALL);
// connect to ldap server
$domain = "example.com";
$ldap = new LDAP();
class LDAP{
public $ldapconn = "";
public $ldap_sadmin;
@rafaelfoster
rafaelfoster / nginx_reverse_proxy.conf
Created January 28, 2016 18:16
Reverse Proxy with Nginx
upstream targetwebservice {
server host2.example.com:8000 weight=1 fail_timeout=300s;
}
#server {
# listen 8081;
# server_name servername.exameple.com;
# add_header Strict-Transport-Security max-age=2592000;
# rewrite ^/.*$ https://servername.exameple.com/ permanent;
#}
server {
@rafaelfoster
rafaelfoster / Parse_SquidLogs_MongoDB.py
Created June 18, 2015 12:37
Script to parse squid Logs to MongoDB
#!/usr/bin/env python
import pymongo,sys
#
# Really lame script to learn the pymongo APIs
# [email protected]
#
logfile = "/var/log/squid/access.log"
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width">
<title>Get geolocation every second</title>
<script>
var getCurrentPositionRequest = 0;
function getTime() {
var now = new Date();
var time = '' + now.getUTCHours() + ':';
@rafaelfoster
rafaelfoster / 0_reuse_code.js
Last active August 29, 2015 14:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@rafaelfoster
rafaelfoster / exchange_owa_enablechangepassword.txt
Created February 18, 2015 18:25
Exchange - Enable users to change their passwords in OWA
On the Client Access Server (CAS), click Start > Run and type regedit.exe and click OK.
Navigate to HKLM\SYSTEM\CurrentControlSet\Services\MSExchange OWA.
Right click the MSExchange OWA key and click New > DWord (32-bit).
The DWORD value name is ChangeExpiredPasswordEnabled and set the value to 1.
Note: The values accepted are 1 (or any non-zero value) for "Enabled" or 0 or blank / not present for "Disabled"
After you configure this DWORD value, you must reset IIS. The recommended method to reset IIS is to use IISReset /noforce from a command prompt.
Important: When changing passwords, users can't use a UPN (for example, [email protected]) in the Domain\user name field in the Change Password window shown below, unless E2010 SP1 RU3 or later has been deployed on the Client Access servers.
@rafaelfoster
rafaelfoster / php_dell_warranty.php
Created February 5, 2015 19:44
Script PHP to UPDATE GLPI Computers with DELL warranty (get from webservice)
<?php
require("config_db.php");
$url = "http://xserv.dell.com/services/assetservice.asmx?WSDL";
$soap = new SoapClient($url,array('soap_version' => SOAP_1_2));
if (! empty($_GET['TAG']) || ! empty($_GET['tag']) ) {
if ( isset($_GET['TAG']) )