Enable hash in the url for routing in Backbone when using bootstrap tabs
Try this code. It adds tab href to url + opens tab based on hash on page load:
$(function(){
var hash = window.location.hash;
hash && $('ul.nav a[href="' + hash + '"]').tab('show');
$('.nav-tabs a').click(function (e) {
$(this).tab('show');
var scrollmem = $('body').scrollTop() || $('html').scrollTop();
window.location.hash = this.hash;
$('html,body').scrollTop(scrollmem);
});
});
Pub-Sub pattern:
var events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
off: function(eventName, fn) {
if (this.events[eventName]) {
for (var i = 0; i < this.events[eventName].length; i++) {
if (this.events[eventName][i] === fn) {
this.events[eventName].splice(i, 1);
break;
}
}
}
},
emit: function (eventName, data) {
if (this.events[eventName]) {
this.events[eventName].forEach(function(fn) {
fn(data);
});
}
}
};
use or create ~/.vimrc
inside put:
" colour
syntax on
" show line numbers
"set nu
" tab size
set tabstop=4
" indent lines
set listchars=tab:\¦\
set list
Convert to HEX with prepad
function toHex(i, pad) {
if (typeof(pad) === 'undefined' || pad === null) {
pad = 6;
}
var strToParse = i.toString(16);
while (strToParse.length < pad) {
strToParse = "0" + strToParse;
}
return strToParse;
}
console.log(toHex(572886, 6));
server {
listen 3000 default_server;
listen [::]:3000 default_server;
server_name redis.donvercety.biz;
index index.html index.htm index.php;
root /var/www/html/redis;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}