//detecting tab key press | |
document.body.addEventListener('keydown', function detector (e) { | |
var keyCode = e.keyCode || e.which; | |
if(keyCode == 9) { | |
console.log( 'Tab detected' ); | |
document.documentElement.className += ' is-keyboarduser'; | |
document.body.removeEventListener('keydown', detector); |
As explained on Don't Be Scared of git rebase, git fetch+rebase
is a better alternative to git pull
; unfortunately it's not as concise.
From now on, use git get
instead of git pull
, a custom command that does this:
# get data from remote
git fetch origin
# rebase the remote branch with the same name as local
The asymmetrical Time Machine menu icon in Yosemite was bugging me, so I fixed it.
Here's how to do it:
- Open Finder
- Press
⌘⇧G
- Go to
/System/Library/CoreServices/Menu Extras/TimeMachine.menu/Contents/Resources
- Replace the four
TM*.pdf
files with the ones found in this ZIP
javascript:window.open(document.location.href,''+Math.random(),'width=320,height=480,top='+(screen.height/2-480/2+Math.random()*100-50)+', left='+(screen.width/2-320/2+Math.random()*100-50)) |
$(function () { | |
var $els; | |
var updateHeight = function () { | |
$els.css('height', ''); // reset previously-set height | |
$els.height($els.height());// set the current height in px | |
}; | |
if (/android/i.test(navigator.userAgent)) { | |
$els = $('ELEMENTS-WITH-VH-UNITS'); | |
updateHeight();//set instantly | |
$(window).on('orientationchange.vh-height-set', updateHeight); |
Make HTML5 form validation cross-browser and with custom callbacks.
Create an HTML form with the correct attributes to enable the HTML Form validation (type
, pattern
and required
) and then call bfrFormValidation.setup
on the form(s) that need to be validated.
The three callbacks, if specified, will be called when validation is not met or met again.
Note: if you need a simple connection icon, check out BitBar and its internet checker plugin.
This program notifies you when Internet goes down and when it comes back up.
It pings Google's DNS every 4 seconds; when a ping fails it quickly tries a few more times and switches to downtime mode. When Internet is available again, the cycle restarts.
$images-count: 4; | |
$slideshow-duration: 6; | |
$slideshow-percentage-per-slide: 100/$images-count; | |
$slideshow-slides-overlap: $slideshow-duration/($images-count+1)+1; | |
.slideshow { | |
overflow: hidden; | |
position: relative; | |
height: 400px; | |
z-index: 0; | |
background-color: $color-golden; |