Skip to content

Instantly share code, notes, and snippets.

View theprogrammerin's full-sized avatar

Ashutosh Agrawal theprogrammerin

View GitHub Profile
@theprogrammerin
theprogrammerin / Readme.md
Last active March 22, 2022 09:37
Curl timing test for a URL

Bash Curl timing test

Usage bash test.sh "<url>" <no_samples>

Params

  • url - sample URL to test.
  • no_samples - no of samples to run. Default: 10
@theprogrammerin
theprogrammerin / slowquery_logger.sh
Created November 26, 2014 09:31
Bash script to fetch the log for that hour from Amazon RDS and push it to ElasticSearch / Kibana
#!/bin/bash
#
# Ashutosh Agrawal
# http://blog.theprogrammer.in
#
#
# This bash script simply fetches the log for that hour from Amazon RDS,
# parse and genarlise it using mysql_slow_log_parser (https://gist.github.com/theprogrammerin/e3206a4ec7a7a4086ac2)
# and then push the parsed log to elastic search using logstash (slowquery.conf)(https://gist.github.com/theprogrammerin/034a3efd849112d166ea)
# For analysis on analytic tool like kibana.
@theprogrammerin
theprogrammerin / slowquery.conf
Last active March 9, 2020 08:48
This is logstash configuration file to parse and push the generalised slow query log generated from [https://gist.github.com/theprogrammerin/e3206a4ec7a7a4086ac2] .
#
#
# Ashutosh Agrawal
# http://blog.theprogrammer.in
#
# 2014-11-20 v1.0
#
# This is logstash [http://logstash.net/] config for parsing the data out of the
# modified slow query generated from
# https://gist.github.com/theprogrammerin/e3206a4ec7a7a4086ac2
@theprogrammerin
theprogrammerin / mysql_slow_log_parser
Last active May 2, 2019 14:37
Mysql slow query [file] log parser. It combines multi line log into a single line. Also adds a generalised query be replacing query data with 'XXX' which can then be used to identify the slow query pattern.
#!/usr/bin/perl
#
# Ashutosh Agrawal
# http://blog.theprogrammer.in
#
# 2014-11-20 v1.0
#
# This script is modified version of SQL parser written by
#
# Nathanial Hendler
@theprogrammerin
theprogrammerin / linkify.php
Last active April 23, 2022 11:25
Converts any url in string to a html http link tag
<?php
function linkify($string)
{
$reg_exUrl = "@(https://|http://|www)[^<>[:space:]]+[[:alnum:]/]@";
$links = array();
preg_match_all($reg_exUrl, $string, $urls);
foreach ($urls[0] as $url) {
$string = str_replace($url, "[[:link:".(count($links)).":]]" , $string);
$force_http = "";
@theprogrammerin
theprogrammerin / loadDev.js
Created March 13, 2014 06:46
Load Jquery & Underscore via console
function loadDev(){
var jq = document.createElement("script");
jq.setAttribute("src","http://code.jquery.com/jquery-2.1.0.js")
document.head.appendChild(jq);
var us = document.createElement("script");
us.setAttribute("src","http://underscorejs.org/underscore.js")
document.head.appendChild(us);
console.log("Loaded Jquery and Underscore")
}
loadDev()