Skip to content

Instantly share code, notes, and snippets.

View shansana's full-sized avatar

Shansana Waruna shansana

View GitHub Profile
@shansana
shansana / gist:77721d64d95aebe34ecbc4de02a5805a
Created October 18, 2023 10:21
Mongo DB dump and restore database using srv/uri (Example Atlas)
# Replace URI, your_db_name and C:\somelocation with your values
mongodump --uri mongodb+srv://dbuser:xxxxxxxxx@cluster0.xxxxx.mongodb.net --authenticationDatabase admin --db your_db_name -o "C:\somelocation\your_db_name"
mongorestore --uri mongodb+srv://dbuser:xxxxxxxxx@cluster0.xxxxx.mongodb.net --authenticationDatabase admin --db your_restore_db_name "C:\somelocation\your_db_name"
@shansana
shansana / gulpfile.js
Last active July 8, 2019 11:54
Minimal Gulp setup with live reload (BrowserSync) + Sass + Js
'use strict';
const autoprefixer = require('gulp-autoprefixer');
const csso = require('gulp-csso');
const del = require('del');
const gulp = require('gulp');
const sass = require('gulp-sass');
const uglify = require('gulp-uglify');
const rename = require("gulp-rename");
const browserSync = require("browser-sync");
@shansana
shansana / webkit-scrollbar-style.css
Created September 25, 2018 05:32
Webkit styles for scrollbar
/* scrollbar */
*::-webkit-scrollbar-track
{
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
background-color: #F5F5F5;
}
*::-webkit-scrollbar
{
@shansana
shansana / currency_format.js
Created March 28, 2018 03:55
Format value to currency, thousands separator and 2 decimal places
function currency(value) {
return value.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
console.log(currency(1000.5));
// logs 1,000.50
@shansana
shansana / responsive.css
Created September 19, 2017 09:04
Media queries for responsive layout CSS
@media only screen and (min-width:1280px) {}
@media (min-width:1024px) and (max-width:1279px) {}
@media (min-width:768px) and (max-width:1023px) {}
@media (min-width:480px) and (max-width:767px) {}
@media screen and (max-width:479px) {}
@shansana
shansana / webpack.config.js
Last active June 24, 2017 14:39 — forked from learncodeacademy/webpack.config.js
Sample Basic Webpack Config
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: "scripts.min.js"
@shansana
shansana / Wordpress_URL_update.txt
Last active April 5, 2017 05:18
Wordpress Site URL update when changing the host
-- Replace http://oldurlhere with your old site url
-- Replace http://newurlhere with your new site url
-- Run the Query
UPDATE wp_options SET option_value = replace(option_value, 'http://oldurlhere', 'http://newurlhere') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://oldurlhere','http://newurlhere');
UPDATE wp_posts SET post_content = replace(post_content, 'http://oldurlhere', 'http://newurlhere');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://oldurlhere','http://newurlhere');
@shansana
shansana / Read_Allow_phpMyAdmin_LAN.txt
Last active March 24, 2017 07:28
Allow Access to phpMyAdmin through LAN using IP - XAMPP
# ---- Edit file Drive:\xampp\apache\conf\extra\httpd-xampp.conf
# ---- Find below code at the bottom of the file
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>
# ---- Replace it with this code
@shansana
shansana / get-working-days.js
Last active September 3, 2021 15:25
JavaScript function to get Working days between 2 days without weekends(Saturday,Sunday) and some custom holidays
var getWorkingDays = function(start,endCount,holidays){
var weekdays = [];
var current = start;
var i = 0;
while(i < endCount){
if (!isWeekEnd(current)) {
weekdays.push(current);
i++;
}