Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀
Building ideas

Jabran Rafique⚡️ jabranr

🚀
Building ideas
View GitHub Profile
@jabranr
jabranr / mysql_backup_cron.sh
Last active Jun 19, 2020
Automatic MySQL dump and backup to Git repo cron job
View mysql_backup_cron.sh
#!/bin/sh
#
# @author: Jabran Rafique <hello@jabran.me>
# @link: http://jabran.me/articles/automatic-database-backup-using-git-hosting/
# Set variables
FULLDATE = $(date +"%Y-%d-%m %H:%M")
NOW = $(date +"%Y-%m-%d-%H-%M")
MYSQL_DUMP = `which mysqldump`
GIT = `which git`
@jabranr
jabranr / image-aspect-ratio.js
Last active Jun 2, 2020
Set image aspect ratio with JavaScript
View image-aspect-ratio.js
/**
* Originally wrote this snippet for Suffragette/Pathé campaign (https://apps.facebook.com/inspiring-women)
*
* The campaign app forms a grid of square images pulled from social APIs based on
* particular hashtags. This snippet sets the new width and
* height based on their natural width and height to maintain the aspect ratio.
* Works best for 1:1 aspect ratio but can be modified to accommodate other ratio.
*
* @param Element|Resource img - An image element/resource from DOM
* @param int expected - Expected width or height
@jabranr
jabranr / harlem-shake-snippet.js
Last active May 1, 2020
Harlem Shake JavaScript bookmarklet
View harlem-shake-snippet.js
/**
* 1. Save the following JavaScript snippet as browser bookmark
* 2. Visit a webpage and click on saved bookmark
* 3. Watch the webpage elements dance
* Original story by Mozilla - https://hacks.mozilla.org/2014/02/html5-css3-and-the-bookmarklet-that-shook-the-web/
*/
javascript:(function(){function c(){var e=document.createElement("link");e.setAttribute("type","text/css");e.setAttribute("rel","stylesheet");e.setAttribute("href",f);e.setAttribute("class",l);document.body.appendChild(e)}function h(){var e=document.getElementsByClassName(l);for(var t=0;t<e.length;t++){document.body.removeChild(e[t])}}function p(){var e=document.createElement("div");e.setAttribute("class",a);document.body.appendChild(e);setTimeout(function(){document.body.removeChild(e)},100)}function d(e){return{height:e.offsetHeight,width:e.offsetWidth}}function v(i){var s=d(i);return s.height>e&&s.height<n&&s.width>t&&s.width<r}function m(e){var t=e;var n=0;while(!!t){n+=t.offsetTop;t=t.offsetParent}return n}function g(){var e=docume
@jabranr
jabranr / iterm-cobalt-2colors.json
Created Nov 17, 2019
iTerm Cobalt2 colors (JSON config)
View iterm-cobalt-2colors.json
{
"Use Non-ASCII Font" : false,
"Tags" : [
],
"Ansi 12 Color" : {
"Green Component" : 0.3333333432674408,
"Blue Component" : 1,
"Red Component" : 0.3333333432674408
},
View .gitignore_global
.rsync_cache
.vagrant
*~
Guardfile
*.swp
.idea
.DS_Store?
.DS_Store
ehthumbs.db
Icon?
@jabranr
jabranr / .gitconfig-default
Last active Sep 19, 2018
Default .gitconfig settings
View .gitconfig-default
[user]
name = Jabran Rafique
email = hello@jabran.me
[color]
ui = true
diff = auto
status = auto
branch = auto
@jabranr
jabranr / README.md
Created Jul 28, 2018 — forked from jonathantneal/README.md
Local SSL websites on macOS Sierra
View README.md

Local SSL websites on macOS Sierra

These instructions will guide you through the process of setting up local, trusted websites on your own computer.

These instructions are intended to be used on macOS Sierra, but they have been known to work in El Capitan, Yosemite, Mavericks, and Mountain Lion.

NOTE: You may substitute the edit command for nano, vim, or whatever the editor of your choice is. Personally, I forward the edit command to Sublime Text:

alias edit="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
@jabranr
jabranr / test.js
Created May 23, 2018 — forked from mscdex/test.js
sharing sessions between node.js and php using redis
View test.js
var express = require('express'),
app = express(),
cookieParser = require('cookie-parser'),
session = require('express-session'),
RedisStore = require('connect-redis')(session);
app.use(express.static(__dirname + '/public'));
app.use(function(req, res, next) {
if (~req.url.indexOf('favicon'))
return res.send(404);
@jabranr
jabranr / config
Last active Apr 10, 2018
ssh config boilerplate
View config
# Save following to ~/.ssh/config
Host {work}.bitbucket.com
HostName {work}.bitbucket.com
IdentityFile ~/.ssh/{work}
Host bitbucket.org
HostName bitbucket.org
IdentityFile ~/.ssh/personal
Host github.com
@jabranr
jabranr / vimrc
Last active Sep 25, 2017
.vimrc file
View vimrc
" Inspired from https://dougblack.io/words/a-good-vimrc.html
" Enable syntax colors
syntax enable
" Set line numbers
set number
set relativenumber
" Set tabs and spaces
You can’t perform that action at this time.