Skip to content

Instantly share code, notes, and snippets.

View gionn's full-sized avatar
⚔️

Giovanni Toraldo gionn

⚔️
View GitHub Profile
@gionn
gionn / jclouds-openstack.java
Last active August 29, 2015 14:01
JClouds OpenStack entercloudsuite.com
ComputeServiceContext context = ContextBuilder.newBuilder("openstack-nova")
.credentials(user, password)
.endpoint("https://api-legacy.entercloudsuite.com:5000/v2.0")
.modules(ImmutableSet.<Module> of(new SLF4JLoggingModule(),
new SshjSshClientModule()))
.buildView(ComputeServiceContext.class);
ComputeService computeService = context.getComputeService();
Template template = computeService.getTemplateBuilder()
@gionn
gionn / mysql.rb
Created May 28, 2014 15:52
Chef mysql example recipe
node.set['mysql']['server_root_password'] = 'yolo'
node.set['mysql']['port'] = '3308'
node.set['mysql']['data_dir'] = '/data'
include_recipe 'mysql::server'
mysql_connection_info = {
:host => 'localhost',
:username => 'root',
:password => node['mysql']['server_root_password']
@gionn
gionn / application.rb
Created May 28, 2014 16:05
Chef php application example recipe
include_recipe "apache2::default"
include_recipe "apache2::mod_php5"
application 'wordpress' do
path '/var/www'
owner 'www-data'
group 'www-data'
repository 'https://github.com/WordPress/WordPress.git'
revision '3.9.1'
end
@gionn
gionn / Dockerfile
Last active August 29, 2015 14:18
Simple example of Dockerfile for nodejs application
FROM ubuntu:14.04
MAINTAINER Giovanni Toraldo
ENV DEBIAN_FRONTEND noninteractive
RUN sed -i s/archive/it.archive/g /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN apt-add-repository ppa:chris-lea/node.js
node_modules
@gionn
gionn / docker.rb
Last active August 29, 2015 14:25 — forked from anonymous/docker.rb
Install aufs module on Ubuntu when needed via chef
#
# Recipe:: docker
#
aufs_exists = `lsmod | grep aufs | wc -l`.strip
if aufs_exists.to_i == 0
kernel_version = node["kernel"]["release"]
package "linux-image-extra-#{kernel_version}" do
@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: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 / 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))
{