Skip to content

Instantly share code, notes, and snippets.

View marshyon's full-sized avatar

jon brookes marshyon

View GitHub Profile
@marshyon
marshyon / test_net_ssh_expect.pl
Created July 29, 2012 13:51
test and demonstrate the use of Net::SSH::Expect Perl module to connect via SSH using key authentication, to known and unknown hosts, running commands and processing captured standard output from those commands
#!/usr/bin/env perl
use warnings;
use strict;
use Date::Parse;
use Net::SSH::Expect;
use POSIX qw(strftime);
# set to a known host on your network
@marshyon
marshyon / PostfixMailLogSummary.pl
Created January 14, 2014 12:37
parses postfix emails using a recipient email and pieces together the 'session' and 'log' entries for each
#!/usr/bin/perl
#==========================================================================
#
# FILE: parse_mail_infolog.pl
#
# USAGE: ./parse_mail_infolog.pl
#
# DESCRIPTION: taken a 'list' ( below ), look for specific email logs first by
# string, then by session ids to extract the entire mail
@marshyon
marshyon / pfm.pl
Last active August 29, 2015 14:02
using Parallel::ForkManager as a simple scheduler to maintain a fixed number of long running forked processes
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use Parallel::ForkManager 0.7.6;
use Time::HiRes qw (sleep);
use POSIX qw(strftime);
my $tmp_dir = '/tmp';
@marshyon
marshyon / google_map_api.html
Last active August 29, 2015 14:12
Google maps API - customising the icon that appears on the map, the info window that appears which can be styled. Replace 99.99999 numbers with latitude and longitude - use an on line resource to plot these - see comments in code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
@marshyon
marshyon / autossh
Created January 22, 2015 16:02
CENTOS : Using SSH and AutoSSH, it is possible to set up resilient port forwarded connections for the like of MySQL replication. When the tunnel has been established, the normal procedure for configuring a Master / Slave applies with a client set up of MASTER_HOST='127.0.0.1', MASTER_PORT = 3307. Ensure on systems that employ selinux to either a…
#!/bin/bash
# autossh daemon
# chkconfig: 345 20 80
# description: autossh daemon
# processname: autossh
DAEMON_PATH="/home/autossh"
DAEMON="/usr/bin/sudo"
DAEMONOPTS="-u autossh /usr/bin/autossh -M 20043 -N -L 3307:127.0.0.1:3306 -p 22 xx.xx.xx.xx"
@marshyon
marshyon / client Apache configuration
Last active August 29, 2015 14:14
centralised logging using rsyslog and apache
in apache2.conf, replace current ErrorLog line with :
ErrorLog "| /usr/bin/logger -t httpderr -i -p local4.error"
then in each virtual add logging :
CustomLog "||/usr/bin/logger -t apache -i -p local5.notice" combined
@marshyon
marshyon / stripNulls.go
Created August 15, 2015 10:26
Simple Go program to read a file line by line, strip null characters using a regular expression and write the output to an output file
package main
import (
"bufio"
"flag"
"fmt"
"os"
"regexp"
)
@marshyon
marshyon / postsApp.html
Created October 1, 2015 18:56
Meteor - linking parent / child ( posts / comments ) collections
<head>
<title>postsApp</title>
</head>
<body>
{{> posts}}
</body>
<template name="posts">
<ul>
@marshyon
marshyon / etc_init_sleep
Created November 4, 2015 11:16
Ubuntu Upstart service plus simple Perl script
description "sleepy server"
start on runlevel [2345]
stop on runlevel [!2345]
# set up an environment variable
env TIME=inf
# restart this process if it dies
respawn
@marshyon
marshyon / Dockerfile
Created November 11, 2015 09:18
Dockerising - MongoDB
FROM ubuntu:14.04
MAINTAINER Jon Brookes
ENV REFRESHED_AT 2015-11-05
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
RUN echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
RUN apt-get update
RUN apt-get install -y mongodb-org
RUN stop mongod
RUN echo manual | sudo tee /etc/init/mongod.override