Skip to content

Instantly share code, notes, and snippets.

View unicolet's full-sized avatar

Umberto Nicoletti unicolet

View GitHub Profile
@unicolet
unicolet / auth.js
Last active December 14, 2015 02:39
An authorization module for Express.
var minimatch = require("minimatch");
var url=require('url');
/*
Example usage:
app.use(auth(
true, // disable access by default
[
{path:"/j_security_check", roles:["EVERYONE"]},
{
"name": "Mappu Backend",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app"
},
"dependencies": {
"express": "3.1.0",
"jade": "*",
@unicolet
unicolet / CheckableListItemView.js
Created February 10, 2013 09:27
Add action support on checkbox click
MyApp.CheckableListItemView = SC.ListItemView.extend({
/** @private in SC.ListItemView
*
* Overridden here to handle events on checkbox
*/
mouseUp: function(evt) {
var ret = sc_super();
// check event was on checkbox
if(this._isInsideCheckbox(evt)) {
var pane = this.get('pane'),
/********************
Core.js
********************/
MyApp = SC.Application.create(
/** @scope MyApp.prototype */ {
NAMESPACE: 'MyApp',
VERSION: '0.1.0',
store: SC.Store.create().from(SC.Record.fixtures)
@unicolet
unicolet / collectd.conf
Last active December 11, 2015 05:59
Configuration for collectd to tail a log file and trigger an OpenNMS UEI whenever a certain pattern occurs. http://unicolet.blogspot.it/2013/01/triggering-opennms-notifications-when.html
Interval 10
LoadPlugin logfile
#LoadPlugin write_graphite
LoadPlugin csv
LoadPlugin threshold
LoadPlugin exec
LoadPlugin tail
<Plugin "logfile">
@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
@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 / 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 / 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 / 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 %}