Skip to content

Instantly share code, notes, and snippets.

@pavelbinar
pavelbinar / Random Number.js
Created August 25, 2013 11:10
JavaScript: random umber
/* Random Number */
var randomNumber = Math.floor(Math.random() * 2);
console.log(randomNumber);
@pavelbinar
pavelbinar / gist:6333285
Last active July 27, 2022 07:49
JavaScript: Random Boolean
/* Random Boolean */
var randomNumber = Math.random() >= 0.5;
console.log(randomNumber);
@pavelbinar
pavelbinar / gist:6640084
Last active December 23, 2015 13:09
Terminal: Force Empty Trash
# run command and log out and log in
sudo rm -ri ~/.Trash
@pavelbinar
pavelbinar / gist:7022223
Created October 17, 2013 09:56
Disable Notification Center Permanently Mac os X
sudo defaults write /System/Library/LaunchAgents/com.apple.notificationcenterui KeepAlive -bool false
# You can re-enable notification center by replacing “false” in the above statement with “true.”
killall NotificationCenter
@pavelbinar
pavelbinar / gist:7343002
Last active December 27, 2015 14:49
Terminal: Fix NPM installation rights
# Source: http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo
# This looks like a permissions issue in your home directory. To reclaim ownership of the .npm directory execute
sudo chown -R `whoami` ~/.npm
# Also you will need the write permission in node_modules directory:
sudo chown -R `whoami` /usr/local/lib/node_modules
@pavelbinar
pavelbinar / gist:7397549
Last active December 27, 2015 22:09
Terminal: Apps/Libraries upgrade commands
# NPM
npm update
# Ruby gems
gem update
# Homebrew
brew upgrade
# yeoman generators
@pavelbinar
pavelbinar / smooth-scrolling.js
Last active December 27, 2015 23:19
JavaScript: Smooth scrolling
// Smooth scrolling
// Source: http://www.paulund.co.uk/smooth-scroll-to-internal-links-with-jquery
$('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
@pavelbinar
pavelbinar / jshint-fix.js
Last active December 27, 2015 23:29
JavaScript: JSHint fix - global $, use strict
/*global $:false */
'use strict';
@pavelbinar
pavelbinar / gist:7413666
Last active December 28, 2015 00:29
JavaScript: Parse float nuber with two decimal places
var twoPlacedFloat = parseFloat(yourString).toFixed(2)
@pavelbinar
pavelbinar / fixed-nav.js
Created November 14, 2013 10:02
JavaScript: Fixed top nav after certain distance from top
// Fixed nav after certain point
// Show the fixed-strip after reachinch 240px from the top
$(window).scroll(function () {
if ($(this).scrollTop() > 240) {
$('.fixed-strip').css('visibility', 'visible');
} else {
$('.fixed-strip').css('visibility', 'hidden');
}
});