Skip to content

Instantly share code, notes, and snippets.

@hardikns
hardikns / prepbuild
Created June 6, 2020 02:30
prepare build
# gets the last tag on the branch
LAST_TAG=`git describe --abbrev=0 --tags`
echo "Features:"
echo ""
echo ""
echo "Commits:"
# git log
git log --oneline --no-decorate $LAST_TAG..${1:-master} | while read line; do echo "* $line"; done
@hardikns
hardikns / gitprune
Created June 6, 2020 02:21
gitprune
git remote prune ${1:-origin}
git branch -D `git branch -vv|grep gone| cut -d ' ' -f 3`
@hardikns
hardikns / ConvertMysqlToPostgres-Sameersbn-gitlab-docker.md
Last active March 27, 2017 19:20
ConvertMysqlToPostgres-Sameersbn-gitlab-docker.md

Convert Mysql DB to Postgresql for Sameersbn/docker-gitlab users

Note: Assume you are using the compose file, if not switch to one its much easy.

Add this to your docker-compose

  postgresql:
    restart: always
    image: sameersbn/postgresql:9.6-2
    volumes:
@hardikns
hardikns / upgrade_postgres_mac.sh
Last active January 23, 2017 19:05
Upgrading Postgres (Mac) with some DB's having postgis
#!/bin/bash
######If the postgis major version changes the below will not work.
### Switch back the binary to old postgresql binary if upgrade has happeneded
brew switch postgresql $OLDVer
## Backup DB which contains postgis and Drop it (upgrade fails otherwise)
pg_dump mysrcm > /tmp/mysrcm.sql
dropdb mysrcm
@hardikns
hardikns / cryptorgraphy_mac_install.sh
Created August 27, 2016 04:42
cryptography install on mac
env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography
@hardikns
hardikns / pg_change_owner.sh
Last active May 15, 2016 19:15
Postgres Change owner
#!/bin/bash
export YOUR_DB=<dbname>
export NEW_OWNER=<new_user>
for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" $YOUR_DB` ; do psql -c "alter table \"$tbl\" owner to $NEW_OWNER" $YOUR_DB ; done
for tbl in `psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" $YOUR_DB` ; do psql -c "alter table \"$tbl\" owner to $NEW_OWNER" $YOUR_DB ; done
for tbl in `psql -qAt -c "select table_name from information_schema.views where table_schema = 'public';" $YOUR_DB` ; do psql -c "alter table \"$tbl\" owner to $NEW_OWNER" $YOUR_DB ; done
@hardikns
hardikns / copyimages.sh
Created January 30, 2016 15:37
Script for Photo segregate into folder
#!/bin/bash
# Commands to rename and move photos to right folder
python copytofolder.py `cd /home/narsi/Dropbox/Camera\ Uploads && find .|grep .jpg`
mv `find .|grep 2012-09`
find . -name '2013-01*'
mkdir /windows/d/Narshu/`date +%Y%m`
find . -name '2013-01*.jpg' -exec mv {} /windows/d/Narshu/201301 \;
@hardikns
hardikns / tables.py
Created January 30, 2016 05:53
Script to give tables test to your kid
#!/usr/bin/python
import random
import sys
import itertools
from multiprocessing import Process, Manager
from time import sleep
def waitforx(time):
sleep(time)
exit(0)
@hardikns
hardikns / Nginx-Proxy.md
Last active June 8, 2018 06:22
How to enable HTTPS on servers using Nginx

How to enable HTTPS on servers using Nginx

This document talks about securing your web application or api using nginx proxy.

    -------------          ----------------           -------------
    |           |          |              |           | Web App   |
    |  Client   +--------->+ nginx server +---------->+    or     |

| | https | | http | Web API |

# Convert iPhone Call history to Droid.
# Step1: Backup your iPhone using iTunes. Copy the call_history.db by following this link
# https://theiphonewiki.com/wiki/Call_History_Database
# (The iTunes Backup filename of call_history.db is 2b2b0084a1bc3a5ac8c27afdf14afb42c61a19ca.)
# Step2: Store the script in the same folder as the call_history.db and run the script
# python call_history_to_droid.py > calls-YYYYMMDDhhmmss.xml
# Use dummy date is also fine.
# Step3: In Android phone install the app CallLogBackupRestore ->
# https://play.google.com/store/apps/details?id=com.riteshsahu.CallLogBackupRestore
# Place the file created in step2 in your phone and restore using the app.