Skip to content

Instantly share code, notes, and snippets.

View gionn's full-sized avatar

Giovanni Toraldo gionn

View GitHub Profile
@gionn
gionn / make_selfsigned_ssl_cert
Created September 26, 2013 19:43
Simple script to generate a self-signed certificate for a domain (use *.domain.tld for a wildcard certificate) to be used on webserver (apache2, nginx).
#!/bin/bash
openssl genrsa 2048 > host.key
openssl req -new -x509 -nodes -sha1 -days 3650 -key host.key > host.cert
openssl x509 -noout -fingerprint -text < host.cert > host.info
cat host.cert host.key > host.pem
chmod 400 host.key host.pem
echo ## put on your nginx virtualhost ##
echo ssl on;
echo ssl_certificate /path/to/host.pem;
@gionn
gionn / gist:6007641
Created July 16, 2013 10:39
OpenNebula working context for Ubuntu VM available on the marketplace
CONTEXT=[
ETH0_GATEWAY="$NETWORK[GATEWAY, NETWORK=\"loc\"]",
ETH0_IP="$NIC[IP, NETWORK=\"loc\"]",
ETH0_MASK="$NETWORK[NETWORK_MASK, NETWORK=\"loc\"]",
ETH0_DNS="$NETWORK[DNS, NETWORK=\"loc\"]",
ETH0_NETWORK="$NETWORK[NETWORK_ADDRESS, NETWORK=\"loc\"]",
TARGET="hda",
SSH_PUBLIC_KEY="yourkey"
]
@gionn
gionn / DefaultController.java
Last active December 14, 2015 19:19
spring-mvc-json-example
package com.liberologico.cloudesire.cmw.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.liberologico.cloudesire.cmw.models.Entity;
@gionn
gionn / gist:5024680
Created February 24, 2013 17:21
Acer TravelMate 5760Z (HuronRiver_CRB)
# Add acpi_backlight=vendor for brightness not working
/etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor"
# Fix for lag and packet loss on wifi - working on 3.2 stock kernel but not on 3.5 backported
07:00.0 Network controller: Atheros Communications Inc. AR9287 Wireless Network Adapter (PCI-Express) (rev 01)
/etc/modprobe.d/ath9k.conf
options ath9k nohwcrypt=1
@gionn
gionn / gist:4739763
Last active May 21, 2019 21:27
Zimbra: automatic fetching of external accounts.

Zimbra automatic fetching of external accounts

Zimbra 8 will not fetch automatically external POP3 or IMAP account. Use the following command to enable it! (every 5 minutes)

zmprov mc default zimbraDataSourcePollingInterval 5m

@gionn
gionn / gist:4737529
Last active December 12, 2015 07:38
Zimbra ignore invalid certificate

Zimbra: how to skip validation for self-signed or invalid certificates

Zimbra 8 will refuse to fetch emails from external accounts if the remote server is using a self-signed (or invalid) SSL certificate. Hence this is a good thing in terms of security, sometimes it isn't possible to control how external mail providers is handling their things.

This limitation is active even if "Use an encrypted connection (SSL) when accessing this server" isn't checked, since Zimbra will automatically use STARTTLS if detects that remote server support it.

$ sudo -i -u zimbra 
$ zmlocalconfig -e javamail_imap_enable_starttls=false
$ zmlocalconfig -e javamail_pop3_enable_starttls=false

$ zmmailboxdctl restart

@gionn
gionn / gist:4564289
Created January 18, 2013 12:29
Bonnie++ on digitalocean.com VPS
root@gionn:~# bonnie++ -u nobody -c 2 -d /tmp
Using uid:65534, gid:65534.
Writing a byte at a time...done
Writing intelligently...done
Rewriting...done
Reading a byte at a time...done
Reading intelligently...done
start 'em...done...done...done...done...done...
Create files in sequential order...done.
Stat files in sequential order...done.
@gionn
gionn / zfs-snapshot.sh
Last active December 10, 2015 16:58 — forked from ertug/zfs-snapshot.sh
zfs-snapshot script, tested under FreeBSD 9.1
#!/usr/local/bin/bash
##
# original code: http://andyleonard.com/2010/04/07/automatic-zfs-snapshot-rotation-on-freebsd/
# 07/17/2011 - ertug: made it compatible with zfs-fuse which doesn't have .zfs directories
##
# Path to ZFS executable:
ZFS=/sbin/zfs
#
# Jekyll migrator for Drupal 7+
# adrianmejia.com
#
require 'rubygems'
require 'sequel'
require 'fileutils'
require 'yaml'
@gionn
gionn / Builder.php
Created December 12, 2012 10:44
Disable HTML escaping for rendering HTML in label for KnpMenu in KnpMenuBundle in Symfony2 (used to embed Twitter Bootstrap Glyphicons)
<?php
// Menu builder class
public function topUserMenu(Request $request)
{
$user = $this->securityContext->getToken()->getUser();
$menu = $this->factory->createItem('root');
$userDrop = $menu->addChild(
'<i class="icon-user icon-white"></i> ' . $user->getFirstname() . ' ' . $user->getLastname(),
array('extras' => array('safe_label' => true))