Skip to content

Instantly share code, notes, and snippets.

View vikalpj's full-sized avatar
🎯
Focusing

Vikalp Jain vikalpj

🎯
Focusing
View GitHub Profile
@vikalpj
vikalpj / P12toPEM.txt
Created February 19, 2020 12:43 — forked from shahdhiren/P12toPEM.txt
Convert P12 file for Push Notification to PEM format
Development Phase:
Step 1: Create Certificate .pem from Certificate .p12
Command: openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
Step 2: Create Key .pem from Key .p12
Command : openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12
Step 3: Optional (If you want to remove pass phrase asked in second step)
Command : openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem
@vikalpj
vikalpj / postgres_table_row_count.sql
Created November 27, 2019 08:34
Row counts for all tables in a postgres db.
SELECT schemaname,relname,n_live_tup
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;
@vikalpj
vikalpj / postgres_queries_and_commands.sql
Created November 30, 2018 08:19 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@vikalpj
vikalpj / upgrade-postgres-9.5-to-9.6.md
Created July 13, 2018 08:21 — forked from delameko/upgrade-postgres-9.5-to-9.6.md
Upgrading PostgreSQL from 9.5 to 9.6 on Ubuntu 16.04

TL;DR

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.6 main --stop
sudo pg_upgradecluster 9.5 main
sudo pg_dropcluster 9.5 main
@vikalpj
vikalpj / ipak.R
Created June 4, 2018 05:59 — forked from stevenworthington/ipak.R
Install and load multiple R packages at once
# ipak function: install and load multiple R packages.
# check to see if packages are installed. Install them if they are not, then load them into the R session.
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
@vikalpj
vikalpj / ecs-pgmajfault-cleaner.sh
Last active February 23, 2018 09:23
Clean up script for ecs containers when container using High memory
#!/bin/bash -e
##
# Use this annotated script as base for killing container misbehaving on reaching memory limit
#
# Requirements:
# - `jq` must be installed on both the client and server
##
# don't kill containers using these images even if they're misbehaving
@vikalpj
vikalpj / ecs-interactive-console.sh
Created January 25, 2018 22:10 — forked from clarkdave/ecs-interactive-console.sh
ecs-interactive-console
#!/bin/bash -e
##
# Use this annotated script a base for launching an interactive console task on Amazon ECS
#
# Requirements:
# - `jq` must be installed on both the client and server
##
# the ECS cluster in which we'll launch the console `default` or `staging`
@vikalpj
vikalpj / Installing pycrypto mac
Created January 23, 2018 10:02
Installing pycryto on mac when error ld: library not found for -lgmp
# solution to ld: library not found for -lgmp
brew install gmp
LIBRARY_PATH=/usr/local/lib/ pip install pycrypto
@vikalpj
vikalpj / Installing PyYAML MAc
Last active January 23, 2018 09:59
Installing PyYAML - error ld: library not found for -lyaml PyAML
# installing yaml
# when error ld: library not found for -lyaml PyAML
brew install libyaml
LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/libyaml/lib/ pip install PyYAML
@vikalpj
vikalpj / mysql_user.sh
Created December 30, 2017 11:05
Create mysql user & db and provide permissions to user for the created db
#!/bin/bash
ERROR=0
MYSQL_ROOT_USER=$1
MYSQL_ROOT_PASSWORD=$2
DB_TO_CREATE=$3
USER_TO_CREATE=$4
PASSWORD_FOR_USER=$5
if [ -z "$MYSQL_ROOT_USER" ]