Skip to content

Instantly share code, notes, and snippets.

View makeittotop's full-sized avatar

abhishek pareek makeittotop

  • Canada
  • 02:47 (UTC -07:00)
View GitHub Profile
@makeittotop
makeittotop / change_definer.sh
Created December 2, 2020 23:45 — forked from cedricmagne/change_definer.sh
Change TRIGGERS DEFINER in MySQL
##
## Create mysql triggers dump
## We add DROP TRIGGER IF EXISTS with option --add-drop-trigger
## This option is supported only by mysqldump as supplied with MySQL Cluster. It is not available when using MySQL Server 5.5.
## If you don't need password dont use -p option.
##
mysqldump -u <USERNANME> -p --routines --add-drop-trigger --no-create-info --no-data --no-create-db --skip-opt <database> > outputfile.sql
##
## Change old DEFINER with sed command
@makeittotop
makeittotop / jq to filter by value.md
Created May 19, 2020 01:53 — forked from ipbastola/jq to filter by value.md
JQ to filter JSON by value

JQ to filter JSON by value

Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'

Example: To get json record having _id equal 611

cat my.json | jq -c '.[] | select( ._id | contains(611))'

Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)

@makeittotop
makeittotop / walg-pitr.md
Created October 3, 2019 05:46 — forked from pohzipohzi/walg-pitr.md
PostgreSQL Point-In-Time-Recovery (PITR) with WAL-G

WAL-G PITR

This gist summarises a way to simulate point-in-time recovery (PITR) using WAL-G. Most of the material is adapted from Creston's tutorial.

Setup

First we initialize a database cluster

pg_ctl init -D cluster
@makeittotop
makeittotop / vault_logrotate
Created September 9, 2019 05:16 — forked from soloradish/vault_logrotate
logrotate setting file for HashiCorp's Vault audit file
# Change the path below to your own audit log path.
/var/log/vault/audit.log {
rotate 30
daily
# Do not execute rotate if the log file is empty.
notifempty
missingok
compress
# Set compress on next rotate cycl to prevent entry loss when performing compression.
delaycompress
@makeittotop
makeittotop / ha-redis-keepalived.conf
Created March 8, 2018 05:27 — forked from nathwill/ha-redis-keepalived.conf
keepalived configuration for tracking redis master
vrrp_script chk_redis_master {
script "redis-cli info replication | grep -q 'role:master'"
interval 2
weight 2
rise 2
fall 2
}
vrrp_instance redis_vip {
interface eth0
@makeittotop
makeittotop / semaphore.py
Created June 11, 2017 00:45 — forked from mastermatt/semaphore.py
Consul Semaphore in Python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import datetime
import json
import logging
import os
import socket
import time
@makeittotop
makeittotop / thundering-herd.pl
Created April 3, 2017 04:42 — forked from kazuho/thundering-herd.pl
thundering herd checker for select-accept pattern
#! /usr/bin/perl
#
# to test:
# 1) run this script with either "accept" or "select-accept" as the argument
# (the script listens to 127.0.0.1:12345)
# 2) telnet localhost 12345
# 3) if you see "accept failed", there is the thundering herd problem
#
#
use strict;
@makeittotop
makeittotop / pedantically_commented_playbook.yml
Created December 20, 2016 01:57 — forked from marktheunissen/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@makeittotop
makeittotop / run-innobackupex.sh
Created December 12, 2016 05:33 — forked from jmfederico/run-xtrabackup.sh
Script to create full/incremental backups with innobackupex script.
#!/bin/sh
TMPFILE="/tmp/innobackupex-runner.$$.tmp"
USEROPTIONS="--user=XXX --password=XXX"
FILTERTABLES="--include=.*[.].*"
BACKDIR=/var/mysql-bak
BASEBACKDIR=$BACKDIR/base
INCRBACKDIR=$BACKDIR/incr
FULLBACKUPLIFE=3600 #604800 # How long to keep incrementing a backup for, minimum 60
KEEP=1 # Keep this number of backups, appart form the one currently being incremented
Question
Is the following SQL good or bad practice from a performance perspective?
Searching for all rows with the year 2012:
CREATE INDEX tbl_idx ON tbl (date_column);
SELECT text, date_column
FROM tbl
WHERE YEAR(date_column) = '2012';