Skip to content

Instantly share code, notes, and snippets.

View unicolet's full-sized avatar

Umberto Nicoletti unicolet

View GitHub Profile
@unicolet
unicolet / sc_query_lang.js
Created August 21, 2012 09:47
Local query with Sproutcore Query language and transient vars
/**
* Created with JetBrains WebStorm.
* User: unicoletti
* Date: 8/21/12
* Time: 11:00 AM
* To change this template use File | Settings | File Templates.
*/
AA={};
@unicolet
unicolet / salt-minion
Created August 24, 2012 16:03
SLES init.d script for salt-minion
#!/bin/bash
#
# Template SUSE system startup script for example service/daemon salt-minion
# Copyright (C) 1995--2005 Kurt Garloff, SUSE / Novell Inc.
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or (at
# your option) any later version.
#
@unicolet
unicolet / poller2provisiond.xslt
Created September 20, 2012 08:48
(rough draft, but working) collects Windows* service names from poller-configuration.xml and outputs a config for provisiond
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:opennms="http://xmlns.opennms.org/xsd/config/poller"
version="1.0">
<xsl:template match="opennms:service">
<xsl:if test="contains(@name, 'Windows')">
<xsl:element name="detector">
<xsl:attribute name="class">org.opennms.netmgt.provision.detector.snmp.Win32ServiceDetector</xsl:attribute>
@unicolet
unicolet / pillar-data
Created October 22, 2012 15:06
manage snmpd with salt
snmp_ro_community: xxxxxxx
snmp_management_station: 10.0.0.1
@unicolet
unicolet / VmReconfigNetwork.groovy
Created October 27, 2012 08:24
Script to reconfigure a vSphere vm first network adapter
import java.net.URL
import com.vmware.vim25.*
import com.vmware.vim25.mo.*
/*
Example invocation:
groovy -cp lib/dom4j-1.6.1.jar:lib/vijava50120120518.jar Sample.groovy 1 2 3 websphere "Network adapter 1" DMZ
*/
@unicolet
unicolet / linuxservers.db
Created October 31, 2012 14:50
Generate a dns zone definition from Salt
@ in soa localhost. root 1 3H 15M 1W 1D
ns localhost.
{% set nets=salt['publish.publish']('*','network.interfaces') %}{% for n in nets %}{% set pdata=salt['publish.publish'](n,'pillar.data') %}{% if pdata.has_key(n) %}{% if pdata[n].has_key('zone') %}{% if pdata[n]['zone']=='linuxservers' %}
{{ n }} IN A {{ nets[n]['eth0']['inet'][0]['address'] }}
{% endif %}{% endif %}{% endif %}{% endfor %}
@unicolet
unicolet / mylistitemview.js
Created November 3, 2012 11:59
Fire when user clicks on the right icon of a SC.ListItemView
/*
* The code below show how to hook into the standard ListItemView implementation
* to add support for events generated on the right icon.
*
* Specify a rightIconTarget/rightIconAction on the ListView definition as you would
* normally do for action/target.
*
*/
P.CustomListItemView = SC.ListItemView.extend({
/** @private in SC.ListItemView
@unicolet
unicolet / Bootstrap.groovy
Created November 10, 2012 18:18
Integrating liquibase into Grails bootstrap
import org.mappu.*
import org.codehaus.groovy.grails.commons.ApplicationHolder
import liquibase.*
import liquibase.util.NetUtil
import liquibase.database.DatabaseFactory;
import grails.util.Environment
class BootStrap {
def dataSource
@unicolet
unicolet / AwesomeRequestWrapper.java
Created December 18, 2012 12:18
A (working, if it doesn't let me know) HttpServletRequestWrapper that supports: * multiple calls to getInputStream, no more pain when writing filters * programmatic injection of the Principal * post params will be fetched from the local request body cache so you can now still call getParameter after someone else called getInpuStream
package java.is.awesome; // joking
import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import javax.servlet.ServletInputStream;
import javax.servlet.http.*;
import java.io.*;
import java.security.Principal;
@unicolet
unicolet / desktoplinksmanager.vbs
Last active December 10, 2015 00:38
Have you ever wanted to be able to manage desktop links by simply setting group membership in Active Directory? With this login script now you can. My second Christmas gift for all sysadmins out there!
Set FSO = CreateObject("scripting.filesystemobject")
Set objShell = WScript.CreateObject("WScript.Shell")
strDesktop = objShell.SpecialFolders("Desktop")
' Could you believe this is a comment? I know, vbs sucks
'
' The following is a dictionary of dictionaries.
' The first dictionary is keyed by group name (case sensitive!)
' while the second holds the attributes for the link to be created.
' With the example cfg below the script will create a link on the desktop