This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function declOfNum(number, titles) { | |
cases = [2, 0, 1, 1, 1, 2]; | |
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ]; | |
} | |
use: | |
declOfNum(count, ['найдена', 'найдено', 'найдены']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Box Shadow</title> | |
<style> | |
.box { | |
height: 150px; | |
width: 300px; | |
margin: 20px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* based on http://www.yuiblog.com/blog/2010/09/27/clearfix-reloaded-overflowhidden-demystified/ */ | |
.cf:before, | |
.cf:after { | |
content: "."; | |
display: block; | |
height: 0; | |
overflow: hidden; | |
} | |
.cf:after {clear: both;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The Babylonian Method | |
// http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method | |
// @param n - the number to compute the square root of | |
// @param g - the best guess so far (can omit from initial call) | |
function squirt(n, g) { | |
if (!g) { | |
// Take an initial guess at the square root | |
g = n / 2.0; | |
} | |
var d = n / g; // Divide our guess into the number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function moveCursorToEnd(el) { | |
if (typeof el.selectionStart == "number") { | |
el.selectionStart = el.selectionEnd = el.value.length; | |
} else if (typeof el.createTextRange != "undefined") { | |
el.focus(); | |
var range = el.createTextRange(); | |
range.collapse(false); | |
range.select(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -------------------------------------------------- | |
// Flexbox LESS mixins | |
// The spec: http://www.w3.org/TR/css3-flexbox | |
// -------------------------------------------------- | |
// Flexbox display | |
// flex or inline-flex | |
.flex-display(@display: flex) { | |
display: ~"-webkit-@{display}"; | |
display: ~"-ms-@{display}box"; // IE10 uses -ms-flexbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// as discussed by Crockford here: http://www.youtube.com/watch?v=dkZFtimgAcM | |
// more detailed example here: https://github.com/douglascrockford/monad/blob/master/monad.js | |
function MONAD() { | |
return function unit(value) { | |
var monad = Object.create(null); | |
monad.bind = function (func) { | |
return func(value); | |
}; | |
return monad; |
We have moved: https://github.com/magnetikonline/linuxmicrosoftievirtualmachines
Due to the popularity of this Gist, and the work in keeping it updated via a Gist, all future updates will take place at the above location. Thanks!
OlderNewer