Skip to content

Instantly share code, notes, and snippets.

@GaryRogers
GaryRogers / logstash.config
Last active December 6, 2016 16:09
Logstash Redis warning pattern
# Redis Debug Config to match on normal and warning Redis log lines.
input {
stdin { codec => "plain" }
}
filter {
grok {
# Extends the normal redis pattern to account for warnings as well.
match => [ "message", "\[%{POSINT:pid}\] %{REDISTIMESTAMP:timestamp} # %{LOGLEVEL:level} %{GREEDYDATA:mymessage}"]
match => [ "message", "\[%{POSINT:pid}\] %{REDISTIMESTAMP:timestamp} \* %{GREEDYDATA:mymessage}"]
@GaryRogers
GaryRogers / elasticsearch
Created May 16, 2014 17:14
Logstash patterns for elasticsearch.log
ELASTICSEARCHTIME \[%{TIMESTAMP_ISO8601:timestamp}\]
ELASTICSEARCHLEVEL \[%{LOGLEVEL:level}\s+\]
ELASTICSEARCHSERVICE \[%{DATA:service}\s+\]
ELASTICSEARCHVERSION \[%{DATA:version}\]
ELASTICSEARCHLOG %{ELASTICSEARCHTIME}%{ELASTICSEARCHLEVEL}%{ELASTICSEARCHSERVICE} %{ELASTICSEARCHVERSION} %{GREEDYDATA:mymessage}
@GaryRogers
GaryRogers / monolog
Created May 16, 2014 21:57
Logstash pattersn for monolog
MONOLOGTIME \[%{TIMESTAMP_ISO8601:timestamp}\]
MONOLOGLEVEL \[%{LOGLEVEL:level}\]
MONOLOGCONTEXT \[context:%{DATA:context}\]
MONOLOGEXTRA \[extra:%{DATA:extra}\]
MONOLOG %{MONOLOGTIME} %{MONOLOGLEVEL} %{MONOLOGCONTEXT}
@GaryRogers
GaryRogers / logstash.conf
Created May 16, 2014 22:02
Monolog Logstash Config example
input {
stdin { codec => "plain" }
}
filter {
# Pulls out fields from monolog text log. (Note, we don't send extra to our monolog)
grok {
match => [ "message", "%{MONOLOG} %{GREEDYDATA:mymessage}"]
}
@GaryRogers
GaryRogers / createPhar.php
Last active March 28, 2020 23:54
Create a Phar archive for PHP
<?php
# Create an executable phar
# Name of our archive.
$phar = new Phar("myscript.phar");
# Have to do buffering to make things executable.
# See http://stackoverflow.com/questions/11082337/how-to-make-an-executable-phar
$phar->startBuffering();
@GaryRogers
GaryRogers / config.xml
Created May 19, 2014 19:37
ant build script for a PHAR Archive
<project name="myproject" default="build" basedir=".">
<property name="build" value="${basedir}/build"/>
<property name="build.src" value="${build}/src"/>
<target name="clean">
<delete dir="${build}" />
</target>
<target name="init">
<mkdir dir="${build}" />
@GaryRogers
GaryRogers / MacOSXPublicKeySSH.md
Last active October 22, 2022 04:10
Set up public key ssh on Mac OS X

Setting up SSH Key Auth on a Mac

Overview

Setting up public key auth allows you to ssh and scp to remote hosts without using your password. It uses encryption keys instead. Typically when you set up a private key it is best practice to set a password on the private key, which would result in a need to enter the private key password every time you want to login to a remote host. Apple has a feature of the MacOS X Keychain that allows you to add this password to your keychain, basically making the unlocking of the private key transparent. You can also change the protection level on this password in Keychain Access to require the keychain password every time it's used.

The gist of what we'll be doing is creating a private key, and then sending the associated public key to the remote host to establish trust between the local system and the remote system.

Procedure

Copy the following code blocks into a terminal window, one after the other. Several will prompt you for passwords, either for your public ke

@GaryRogers
GaryRogers / ComposerPHPUnit.md
Last active May 15, 2023 16:01
Getting Composer and PHPUnit to autoload namespaces

Getting Composer and PHPUnit to autoload namespaces.

Overview

Details

Project Structure

ProjectRoot
 src
@GaryRogers
GaryRogers / monolog_table.sql
Created May 28, 2014 21:06
Monolog Oracle Table
CREATE TABLE
MONOLOG
(
ID NUMBER(11) NOT NULL,
LOG_TIME TIMESTAMP(6),
LOG_LEVEL VARCHAR2(20),
LOG_HOSTNAME VARCHAR2(512),
LOG_USER VARCHAR2(30),
LOG_IP VARCHAR2(45),
LOG_MESSAGE CLOB,
@GaryRogers
GaryRogers / OracleHander.php
Created May 28, 2014 21:07
Monolog Oracle Handler
<?php
namespace Monolog\Handler;
use Monolog\Logger;
use Monolog\Formatter\LineFormatter;
// https://github.com/Seldaek/monolog/blob/master/doc/extending.md
class OracleHandler extends AbstractProcessingHandler {