Skip to content

Instantly share code, notes, and snippets.

View gionn's full-sized avatar
⚔️

Giovanni Toraldo gionn

⚔️
View GitHub Profile
@gionn
gionn / gist:1543538
Created December 31, 2011 09:36
Freeze on Sony Vaio VPCS13V9E Linux 3.1.0-1-amd64, Corsair CSSD-F60GB2 with discard enabled, nouveau 1:0.0.16+git20111201+b5534a1-1
Dec 31 10:31:18 sony-stark kernel: [ 537.078969] ata2.00: qc timeout (cmd 0xa0)
Dec 31 10:31:18 sony-stark kernel: [ 537.078983] ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
Dec 31 10:31:18 sony-stark kernel: [ 537.078986] ata2.00: irq_stat 0x40000001
Dec 31 10:31:18 sony-stark kernel: [ 537.078991] sr 1:0:0:0: CDB: Test Unit Ready: 00 00 00 00 00 00
Dec 31 10:31:18 sony-stark kernel: [ 537.079001] ata2.00: cmd a0/00:00:00:00:00/00:00:00:00:00/a0 tag 0
Dec 31 10:31:18 sony-stark kernel: [ 537.079003] res 51/20:03:00:00:00/00:00:00:00:00/a0 Emask 0x5 (timeout)
Dec 31 10:31:18 sony-stark kernel: [ 537.079006] ata2.00: status: { DRDY ERR }
Dec 31 10:31:18 sony-stark kernel: [ 537.079014] ata2: hard resetting link
Dec 31 10:31:18 sony-stark kernel: [ 537.398702] ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
Dec 31 10:31:23 sony-stark kernel: [ 540.600632] ------------[ cut here ]------------
@gionn
gionn / gist:2308768
Created April 5, 2012 07:31
Drupal 7 customize search form block - template.php
<?php
function theme_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'search_block_form') {
$form['search_block_form']['#title'] = t('Search'); // Change the text on the label element
$form['search_block_form']['#title_display'] = 'invisible'; // Toggle label visibilty
//$form['search_block_form']['#size'] = 40; // define size of the textfield
$form['search_block_form']['#default_value'] = t('Search'); // Set a default value for the textfield
//$form['actions']['submit']['#value'] = t('GO!'); // Change the text on the submit button
$form['actions']['submit'] = array('#type' => 'image_button', '#src' => base_path() . path_to_theme() . '/immagini/btnCerca.png');
@gionn
gionn / gist:2767396
Created May 22, 2012 07:47
Drupal 7 ~ Retrieve last page nid
template.php template_preprocess_page()
<?php
if ($node->type == 'page') {
$result = db_query("SELECT nid FROM {node} WHERE type = 'page' AND status=1 ORDER BY created DESC LIMIT 1");
$arr = $result->fetchAssoc();
$variables['last_page_nid'] = $arr['nid'];
}
?>
@gionn
gionn / gist:2941287
Last active October 6, 2015 05:08
Nagios/Icinga: "Warning: This plugin must be either run as root or setuid root."

Nagios: plugins needing root privilege

the check_dhcp, check_icmp and maybe others plugins require root privileges to run, because of the low-level packet mangling that they perform. but, in the interest of the "safe default", these plugins will not be installed with the suid bit set. there are two recommended ways about overriding this on your system:

  • set the suid bit with dpkg-statoverride:
@gionn
gionn / import.sh
Created June 27, 2012 09:00
Migration script from Windows DNS to PowerDNS
#!/bin/bash
DOMAINARRAY=`cat /mnt/samba/winnt/system32/dns/domainlist`
for domainname in $DOMAINARRAY
do
echo " "
echo "$domainname being imported"
zone2sql --zone=$domainname.dns --gmysql --zone-name=$domainname | mysql -h
10.10.1.1 -D pdns -u pdns
echo "$domainname done!"
@gionn
gionn / pfdel.perl
Created July 10, 2012 15:29
pfdel - deletes message containing specified address from Postfix queue. Matches either sender or recipient address.
#!/usr/bin/perl -w
#
# pfdel - deletes message containing specified address from
# Postfix queue. Matches either sender or recipient address.
#
# Usage: pfdel <email_address>
#
use strict;
@gionn
gionn / email_regexp.php
Created July 25, 2012 14:51
Email Regexp
<?php
# URL that generated this code:
# http://txt2re.com/index-php.php3?s=remember@me.com&1
$txt='remember@me.com';
$re1='([\\w-+]+(?:\\.[\\w-+]+)*@(?:[\\w-]+\\.)+[a-zA-Z]{2,7})'; # Email Address 1
if ($c=preg_match_all ("/".$re1."/is", $txt, $matches))
{
@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))
#
# Jekyll migrator for Drupal 7+
# adrianmejia.com
#
require 'rubygems'
require 'sequel'
require 'fileutils'
require 'yaml'
@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