Skip to content

Instantly share code, notes, and snippets.

View fazlurr's full-sized avatar

Fazlur Rahman fazlurr

View GitHub Profile
.header-main {
border-bottom: 1px solid #ebebeb;
}
.header-main.sticky-header {
border-bottom-color: transparent;
}
.header-v2 .navbar-nav > li > a:before {
bottom: -1px;
<?php
/**
* @param string $url
* @see https://stackoverflow.com/a/51246730/5627904
*/
function get_youtube_id($url) {
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
function hexToRgb(hex) {
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function(m, r, g, b) {
return r + r + g + g + b + b;
});
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
/**
* Decode URI Component safe to use with single %
*
* @param {string} s String to Decode
* @return {string} Decoded Result
*
* @see https://stackoverflow.com/a/54310080/5627904
*/
export const decodeURIComponentSafe = (s) => {
if (!s) return s;
function printcontent() {
var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,";
disp_setting+="scrollbars=yes,width=300, height=350, left=50, top=25";
var content_vlue = document.getElementById("content").innerHTML;
var w = window.open("","", disp_setting);
w.document.write(content_vlue); //only part of the page to print, using jquery
w.document.close(); //this seems to be the thing doing the trick
w.focus();
w.print();
w.close();
@fazlurr
fazlurr / mongodb-s3-backup.sh
Created May 22, 2019 05:43 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
@fazlurr
fazlurr / backup-mongodb-to-s3.sh
Created May 22, 2019 05:43 — forked from caraboides/backup-mongodb-to-s3.sh
Simple script to backup MongoDB to S3, without waste diskspace for temp files. And a way to restore from the latest snapshot.
#!/bin/sh
set -e
HOST=localhost
DB=test-entd-products
COL=asimproducts
S3PATH="s3://mongodb-backups-test1-entd/$DB/$COL/"
S3BACKUP=$S3PATH`date +"%Y%m%d_%H%M%S"`.dump.gz
S3LATEST=$S3PATH"latest".dump.gz
/usr/bin/aws s3 mb $S3PATH
var checkHTML = function(html) {
var doc = document.createElement('div');
doc.innerHTML = html;
return ( doc.innerHTML === html );
}