Skip to content

Instantly share code, notes, and snippets.

Avatar

Gary Rogers GaryRogers

View GitHub Profile
@GaryRogers
GaryRogers / logstash.config
Last active Dec 6, 2016
Logstash Redis warning pattern
View logstash.config
# 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
Logstash patterns for elasticsearch.log
View elasticsearch
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
Logstash pattersn for monolog
View 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
Monolog Logstash Config example
View logstash.conf
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 Mar 28, 2020
Create a Phar archive for PHP
View createPhar.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
ant build script for a PHAR Archive
View config.xml
<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 Feb 5, 2018
Set up public key ssh on Mac OS X
View MacOSXPublicKeySSH.md

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 Jul 24, 2020
Getting Composer and PHPUnit to autoload namespaces
View ComposerPHPUnit.md

Getting Composer and PHPUnit to autoload namespaces.

Overview

Details

Project Structure

ProjectRoot
 src
View monolog_table.sql
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
Monolog Oracle Handler
View OracleHander.php
<?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 {
You can’t perform that action at this time.