Instantly share code, notes, and snippets.

🚀
Developing ideas

Jabran Rafique⚡️ jabranr

View GitHub Profile
@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
@jabranr
jabranr / distance.js
Last active Sep 17, 2017
(Math) Find distance between two known points
View distance.js
// Point a1
// Point a2
let dx = a2.x - a1.x;
let dy = a2.y - a1.y;
let distance = Math.sqrt(dx*dx + dy*dy);
@jabranr
jabranr / loop.js
Last active Sep 17, 2017
(Math) Generate a loop with maximum range
View loop.js
// Increase until a range is met then start again:
let range = 10;
let x = (x + 1) % range;
@jabranr
jabranr / Cache.js
Last active Jan 5, 2017
[JavaScript] Cache data in memory
View Cache.js
/**
* This snippet is now a small library!
* @link https://github.com/jabranr/js-memcache
*/
View .gitignore_global
.rsync_cache
.vagrant
*~
Guardfile
*.swp
.idea
.DS_Store?
.DS_Store
ehthumbs.db
Icon?
@jabranr
jabranr / toggle-multiple-buttons-with-different-text.js
Last active Sep 5, 2016
[jQuery] Toggle multiple buttons at same with different text
View toggle-multiple-buttons-with-different-text.js
$.fn.extend({
disableCta: function() {
this.prop('disabled', true);
// or use your own class
this.addClass('btn--disabled');
// retain current text of the CTA in custom data attribute
// Used html() assuming it is a <button> element
this.attr('data-value', this.html());
@jabranr
jabranr / BaseEntity.php
Last active Jul 25, 2016
[POC DRY] BaseEntity class to be used as base for Entities in Symfony2.
View BaseEntity.php
<?php
namespace Foo\Bar\Entity;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping as ORM;
/**
* BaseEntity
*