Skip to content

Instantly share code, notes, and snippets.

View ganapathichidambaram's full-sized avatar
🎯
Focusing

Ganapathi Chidambaram ganapathichidambaram

🎯
Focusing
View GitHub Profile
S No Parts

Size

( Bytes )

Description
1 Boot Loader 446 Boot loader to load the kernel into the memory to the start the operating system
@ganapathichidambaram
ganapathichidambaram / psql_modify_column_to_varchar.sql
Last active November 11, 2019 09:08
Alter Postgresql table column to varchar from integer or other datatype
-- SQL : PostgreSQL
-- tablename - Name of the table which we want to alter the column
-- columnname - Name of the columnn which we want to change to varchar from other datatype.
ALTER TABLE
tablename
ALTER COLUMN
columnname type varchar using columnname::varchar;
@ganapathichidambaram
ganapathichidambaram / postgresql-kill-session.sql
Last active November 11, 2019 09:08
Kill Active Session of Postgresql DB
-- SQL : Postgresql
-- Query : Kill all the active connection of particular database.
SELECT
pg_terminate_backend(pid)
FROM
pg_stat_activity
WHERE
pid <> pg_backend_pid()
AND datname = 'dev'; -- dev- Database Name which connection needs to be terminate
@ganapathichidambaram
ganapathichidambaram / mysql-import-script.sh
Last active November 11, 2019 09:06
Import SQL file into MYSQL DB
#!/bin/sh
# store start date to a variable
imeron=`date`
echo "Import started: OK"
dumpfile="/home/bob/bobiras.sql"
ddl="set names utf8; "
ddl="$ddl set global net_buffer_length=1000000;"
@ganapathichidambaram
ganapathichidambaram / Airflow Default PostgresOperator.py
Last active November 11, 2019 09:06
Default Postgresql Operator Script of Airflow framework
from airflow.hooks.postgres_hook import PostgresHook
from airflow.models import BaseOperator
from airflow.utils.decorators import apply_defaults
class PostgresOperator(BaseOperator):
"""
Executes sql code in a specific Postgres database
@ganapathichidambaram
ganapathichidambaram / datasourcetocsv_operator.py
Created November 11, 2019 07:10
Airflow - Postgresql DataSource to CSV export
from airflow.hooks.postgres_hook import PostgresHook
from airflow.models import BaseOperator
from airflow.utils.decorators import apply_defaults
from datetime import datetime, timedelta
from os import environ
import csv
class DataSourceToCsvOperator(BaseOperator):
"""
@ganapathichidambaram
ganapathichidambaram / modify_issue_file_linux.sh
Last active November 11, 2019 09:07
Professional linux etc_issue file
#!/bin/sh
cat <<EOT > /etc/issue
***********************************************************************
* Access to this computer system is limited to authorised users only. *
* Unauthorised users may be subject to prosecution under the Crimes *
* Act or State legislation *
* *
* Please note, ALL CUSTOMER DETAILS are confidential and must *
* not be disclosed. *
@ganapathichidambaram
ganapathichidambaram / sample-kickstart-post-script-1.cfg
Last active November 11, 2019 09:07
Sample Post Installation KickStart Script - Anaconda
#
# Set up the serial console
#
%post
echo ":: Setting up Serial Console ::" >> /root/post.log
perl -p -i -e 's/^(default.*)$/$1\nserial --unit=0 --speed=9600 --data=8 --parity=no --stop=1\nterminal --timeout=5 serial console/' /boot/grub/grub.conf >> /root/post.log 2>&1
perl -p -i -e 's/^(\s+kernel.*)$/$1 console=tty0 console=ttyS0,9600/' /boot/grub/grub.conf >> /root/post.log 2>&1
echo "" >> /etc/inittab
echo "# Run serial console on ttyS0" >> /etc/inittab
echo "S1:2345:respawn:/sbin/agetty ttyS0 9600 vt100" >> /etc/inittab
@ganapathichidambaram
ganapathichidambaram / Sample-kickstart configuration-partition.cfg
Last active November 11, 2019 09:05
Few Sample of pre installation script using kickstart configuration for Custom partition by checking list of disk
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# START pre-kvmhost-partitions
#
set \$(list-harddrives)
echo "\$@"
disk=( \$1 \$3 )
size=( \$2 \$4 )
@ganapathichidambaram
ganapathichidambaram / steps to recover corrupted InnoDB table.md
Last active November 11, 2019 09:04
Steps to Recover MariaDB InnoDB corrupted table

Steps to Recover InnoDB Tables

  1. Stop mysqld.

  2. Backup /var/lib/mysql/ib* files for safety reason.

  3. Add the following line into /etc/my.cnf:

    innodb_force_recovery = 1