Skip to content

Instantly share code, notes, and snippets.

View fintanmm's full-sized avatar

Fintan MacMahon fintanmm

View GitHub Profile
@fintanmm
fintanmm / libreoffice
Created February 28, 2014 14:42
LibreOffice headless server script
#!/bin/bash
# LibreOffice headless server script
#
# chkconfig: 2345 80 30
# description: headless openoffice server script
# processname: libreoffice
#
# Author: Vic Vijayakumar
# Modified by Federico Ch. Tomasczik
# and then by Mark Pavlichuk
@fintanmm
fintanmm / 0_reuse_code.js
Last active August 29, 2015 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
no-resolv
resolv-file=/etc/resolv.dnsmasq.conf
interface=docker0
dhcp-range=172.17.42.64,172.17.42.126
dhcp-no-override
# dhcp-leasefile=/etc/dnsmasq.d/default.leases
dhcp-lease-max=127
dhcp-host=52:54:00:29:94:d0,my-filer,172.17.42.80,12h
dhcp-option=option:domain-search,site
dhcp-script=/usr/bin/update-docker-dns.sh
@fintanmm
fintanmm / grok-dhcp-logstash
Last active April 13, 2016 11:17
Grok pattern for logstash from a syslog server
DHCPACTION (ACK|DECLINE|DISCOVER|INFORM|NAK|OFFER|RELEASE|REQUEST)
DHCPGATEWAY %{IPV4:dhcp_gateway_ip}
DHCPMESSAGE ((:)%{SPACE}%{GREEDYDATA:dhcp_message})?
DHCPIPORMAC ((%{IPV4:dhcp_client_ip})|(%{COMMONMAC:dhcp_client_mac}))
DHCPD (?:%{SYSLOGTIMESTAMP:timestamp}|%{TIMESTAMP_ISO8601:timestamp8601})%{SPACE}%{DHCPACTION:dhcp_action}%{SPACE}(for|on|from|to)%{SPACE}%{DHCPIPORMAC}%{SPACE}((from|to)%{SPACE})?%{DHCPIPORMAC}?(\(%{DHCPIPORMAC}\))?%{SPACE}(\(%{USER:user_machine}\))?%{SPACE}?(via|from)%{SPACE}((%{DHCPGATEWAY}%{DHCPMESSAGE})|%{USERNAME:dhcp_client_interface})
DHCPIPSUBNET (?<![0-9])(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))[\/]%{INT}
DHCPDDUP (%{IPV4:dhcp_client_ip})%{GREEDYDATA}(%{COMMONMAC:dhcp_client_mac})%{GREEDYDATA}(%{DHCPIPSUBNET:dhcp_subnet})
DHCPDINFO %{GREEDYDATA:dhcp_message}
DHCPDPOOL pool (%{GREEDYDATA:dhcp_pool})(%{DHCPIPSUBNET:dhcp_subnet})%{GREEDYDATA:dhcp_message}
@fintanmm
fintanmm / archive_clean.py
Last active October 27, 2016 14:49
Simple archive and clean postgresql wal files.
from os import listdir, setgid, setuid
from subprocess import call
import psycopg2
# We run the sql as the postgres user
setgid(104)
setuid(109)
conn = psycopg2.connect("user=postgres")
cur = conn.cursor()
@fintanmm
fintanmm / listmodels.sql
Created December 14, 2016 16:06
List the models paths in Alfresco
select alf_content_url.content_url
from alf_node
left join alf_qname on alf_node.type_qname_id = alf_qname.id
left join alf_node_properties on alf_node_properties.node_id = alf_node.id
join alf_content_data on alf_content_data.id = alf_node_properties.long_value
left join alf_content_url on alf_content_url.id = alf_content_data.content_url_id
where
alf_qname.local_name = 'dictionaryModel'
and alf_content_url.content_url is not null
@fintanmm
fintanmm / fixmetadata.get.js
Last active October 2, 2019 12:19
Fixing metadata within Alfresco.
/**
* Summary. Attempts to fix metadata that is in the Alfresco Repo.
* @param {object} args
*/
const invalidArg = function (message) {
status.code = 400
status.message = message
status.redirect = true
}
@fintanmm
fintanmm / windows1251ToUTF8.py
Last active June 22, 2018 05:28
Parses log file from alfresco bulk import tool then runs convmv on files
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse, sys, re, signal
from subprocess import call
parser = argparse.ArgumentParser()
parser.add_argument("--file", help="The log file to parse.")
parser.add_argument(
"--notest", help="Use --notest to finally rename the files.", action="store_true")
parser.add_argument("--printtest", help="Just print out line contents")
import java.io.File
import org.apache.poi.ss.usermodel.WorkbookFactory
import org.apache.poi.ss.usermodel.{Row, Cell}
val baseUnitFile = new File("./BaseUnits_export_.xlsx")
var workbook = WorkbookFactory.create(baseUnitFile)
val sheet = workbook.getSheetAt(0)
val xmlTemplate = (DevName: Cell, IP: Cell) => <MirrorOp>
<Device>
@fintanmm
fintanmm / findingFiles.sh
Last active March 27, 2019 11:25
Finding info about files and directories
#!/bin/bash
export project=$1
export pathOfProject=$2
mkdir -p "./$project"
# find data/B8493 -type f -printf '%h\n' | sort -u
echo "Empty Dirs"