Skip to content

Instantly share code, notes, and snippets.

View nikkanetiya's full-sized avatar

Nikunj Kanetiya nikkanetiya

View GitHub Profile
@nikkanetiya
nikkanetiya / db_backup.sh
Created August 17, 2017 05:25 — forked from willvincent/db_backup.sh
Intended for use with cron. This script will backup all (or one specific) database, the specified user has access to on the given DB server, and remove backups older than the specified duration to keep them for. If no params are passed, defaults will be used. and backups created for _every_ database.
#!/bin/bash
USAGE="$0 [-u <user> -p <password> -h <host> -P <PORT> -d <database> -D <destination/directory/without/trailing/slash>]"
DESTINATION=`pwd`
USER=root
PASS=root
HOST=localhost
PORT=3306
# SPECIFY HOW LONG TO RETAIN BACKUPS
@nikkanetiya
nikkanetiya / Enable Gzip in Nginx
Last active September 1, 2017 14:55
Enable Gzip in Nginx Server
cat > /etc/nginx/conf.d/gzip.conf << EOF
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
application/atom+xml
application/javascript
application/json
@nikkanetiya
nikkanetiya / axios-nprogress.js
Created September 6, 2017 12:40
NProgress bar with axios
import 'nprogress/nprogress.css'
import NProgress from 'nprogress'
import axios from 'axios'
const calculatePercentage = (loaded, total) => (Math.floor(loaded * 1.0) / total)
const setupUpdateProgress = () => {
axios.defaults.onDownloadProgress = e => {
const percentage = calculatePercentage(e.loaded, e.total)
@nikkanetiya
nikkanetiya / .bash_aliases
Created September 15, 2017 05:38
My Bash Aliases
function pushme {
br=`git branch | grep "*"`
params=''
for i in $*;
do
params=" $params $d$i"
done
git add --all
@nikkanetiya
nikkanetiya / gaps.scss
Created November 10, 2017 07:04
Generate CSS spacing classes from SCSS
$sizeUnit: rem;
$marginKey: 'm';
$paddingKey: 'p';
$separator: '-';
$sizes: ( ('none', 0), ('xxs', 0.125), ('xs', 0.25), ('sm', 0.5), ('md', 1), ('lg', 2), ('xl', 4), ('xxl', 8), );
$positions: ( ('t', 'top'), ('r', 'right'), ('b', 'bottom'), ('l', 'left'));
@function sizeValue($key, $value) {
@return if($key=='none', 0, $value + $sizeUnit);
}
@nikkanetiya
nikkanetiya / filters.js
Created November 10, 2017 09:27
Vue.js Filter to Format DateTime string to readable/custom format
import Vue from 'vue'
import moment from 'moment'
Vue.filter('formatDate', function (value) {
if (value) {
return moment(String(value)).format('MM/DD/YYYY hh:mm')
}
})
@nikkanetiya
nikkanetiya / dump.sql
Created September 7, 2018 05:43
MySql Ignore multiple Table from Dump
mysqldump -u root -p database --ignore-table=database.table1 --ignore-table=database.table2 > dump.sql
@nikkanetiya
nikkanetiya / Kernel.php
Created January 16, 2019 13:12
Cors Config
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
@nikkanetiya
nikkanetiya / node
Created June 3, 2019 13:36
Change version of node
# npm cache clean -f
# npm install -g n
# n stable