Skip to content

Instantly share code, notes, and snippets.

@strarsis
strarsis / gist:9678545f91d76a3a7afa307c7389435b
Created December 5, 2016 23:01 — forked from mjpowersjr/gist:740a9583e9ec8b49e0a3
Parsing the MySQL slow query log via Logstash (the easy way?)

The MySQL slow query log is a difficult format to extract information from. After looking at various examples with mixed results, I realized that it's much easier to configure MySQL to write the slow query log to a table in CSV format!

From the MySQL documentation:

By default, the log tables use the CSV storage engine that writes data in comma-separated values format. For users who have access to the .CSV files that contain log table data, the files are easy to import into other programs such as spreadsheets that can process CSV input.

my.cnf

Note: don't forget to open up permissions on your slow query log CSV file so logstash can read it!

# enable slow query log
@strarsis
strarsis / maillog.json
Created December 7, 2016 22:59 — forked from TinLe/maillog.json
maillog elasticsearch mapping template
{
"template" : "maillog-*",
"order" : 1,
"settings" : {
"number_of_shards" : 2,
"index.refresh_interval" : "90s"
},
"mappings" : {
"maillog" : {
"properties" : {
@strarsis
strarsis / logstash.conf
Created December 7, 2016 22:59 — forked from TinLe/logstash.conf
my logstash.conf file for postfix
input {
file {
path => "/var/log/maillog*"
exclude => "*.gz"
start_position => "beginning"
type => "maillog"
}
}
filter {
if [type] == "maillog" {
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@strarsis
strarsis / catVagrantfilePure.sh
Created February 26, 2017 15:36 — forked from fedir/catVagrantfilePure.sh
Strip Vagrantfile from comments and empty lines
#!/bin/bash
cat Vagrantfile | grep -vE '(^[[:space:]]*($|(#|!|;|//)))'
cat Vagrantfile | grep -vE '(^[[:space:]]*($|(#)))'
@strarsis
strarsis / deploy-hooks share-after.yml
Created April 2, 2017 21:30 — forked from mockey/deploy-hooks share-after.yml
Add wp language files on trellis deploy
---
- block:
- name: Install language files
command: wp core language install {{ item }}
args:
chdir: "{{ deploy_helper.new_release_path }}"
# check for existance of po-file, language install should only run once:
creates: "{{ deploy_helper.new_release_path }}/web/app/languages/{{ item }}.po"
with_items: "{{ project.languages }}"
@strarsis
strarsis / gist:fd3c5b3381b1ac5d5534e742063fab6d
Created May 8, 2017 21:41 — forked from seamusleahy/gist:3098949
Create a curve to text using Lettering.js, Sass, and Compass
/* Add a wave alignment to your title text using Sass, Compass, and Lettering.js.
*
* Lettering.js wraps each letter with a span with a class of .char<#>.
* Compass provides math functions including the sin which provides the wave form.
*/
$length: 11; // The word is 11 letters long
@for $i from 1 through $length {
.char#{$i} {
@include transform(translateY( sin(($i - 1)/($length - 1)*2*pi()) * -25px) );
@strarsis
strarsis / change_post_menu_label.php
Created May 20, 2017 13:24 — forked from nciske/change_post_menu_label.php
WordPress Change Post to Article
<?php
/* Change Post to Article */
function change_post_menu_label() {
global $menu;
global $submenu;
$menu[5][0] = 'Articles';
$submenu['edit.php'][5][0] = 'Articles';
$submenu['edit.php'][10][0] = 'Add New';
$submenu['edit.php'][16][0] = 'Tags';
@strarsis
strarsis / one-page-nav.js
Created May 26, 2017 18:40 — forked from jpen365/one-page-nav.js
One-page nav code for twenty seventeen
/*
One page nav code
*/
jQuery( document ).ready(function(){
/* Add padding and id's to each front page section */
jQuery( "h2.entry-title" ).each( function() {
var panelId = jQuery( this ).html().toLowerCase().replace(/\s+/g, "-");
jQuery( this ).wrapInner(function() {
return "<span style='padding-top:96px;' id='" + panelId + "'></span>";
function tattoo_submit() {
if (isset($_POST["addtattoo"])) {
$title = "Tattoo : ". $_POST["tatooInput"];
$my_post = array(
'post_title' => $title,
'post_status' => 'publish',
'post_author' => 1,