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
var pluralRu = function pluralRu(value) { | |
if (arguments.length != 4) throw "Wrong number of arguments" | |
var number = Math.abs(value), | |
one = arguments[1] || '', two = arguments[2] || '', five = arguments[3] || ''; | |
number %= 100; | |
if (number >= 5 && number <= 20) return five; | |
number %= 10; | |
if (number == 1) return one; | |
if (number >= 2 && number <= 4) return two; |
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
Date.prototype.leap = function(){ | |
var year = this.getFullYear(); | |
return (!(year % 4) && (year % 100) || !(year % 400)); | |
}; |
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
_.mixin({ | |
inGroupsOf: function(array, number, fillWith) { | |
fillWith = fillWith || null; | |
var index = -number, slices = []; | |
if (number < 1) return array; | |
while ((index += number) < array.length) { | |
var s = array.slice(index, index + number); | |
while(s.length < 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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
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
/* simple */ | |
var extends = function(child, parent) { | |
var F = function() { } | |
F.prototype = parent.prototype | |
child.prototype = new F() | |
child.prototype.constructor = child | |
child.superclass = parent.prototype | |
} | |
/* from CoffeeScript */ |
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
oneTimePer = (ms, func) -> | |
ms or (ms = 1000) | |
-> | |
self = arguments.callee | |
self._lastTimeCalled = new Date unless self.hasOwnProperty("_lastTimeCalled") | |
if new Date - self._lastTimeCalled > ms | |
self._lastTimeCalled = new Date | |
func.apply this, arguments | |
myFunc = oneTimePer 2000, (x, y) -> x + y |
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
$page_width: 850px; | |
@function grid_width($width, $margin, $columns) { | |
@return ($width - ($margin * ($columns - 1))) / $columns; | |
} | |
@mixin grid-column($columns, $prefix, $sufix, $gutter, $border_right, $border_left, $cw, $cm) { | |
$width: (($cw + $cm) * $columns) - $cm; | |
$prefix_width: ($cw + $cm) * $prefix; | |
$sufix_width: ($cw + $cm) * $sufix; |
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
#!/usr/bin/env bash | |
set -e | |
SETTINGS=$2 | |
DB_USER="dbuser" | |
DB_NAME="dbname" | |
DB_PASS="dbpass" | |
DB_HOST=localhost |
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
start = | |
element | |
validchar = [0-9a-zA-Z\-_\{\}\.\:\/] | |
_ = [ \t\r\n]* | |
tagAttrs = | |
_ name:validchar+ '="' value:validchar+ '"' _ { |
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
// with array. More more more faster | |
Array.apply(null, Array(100)).map((_, i) => { | |
var n = i + 1; | |
return (n % 3 === 0 && n % 5 === 0 ? 'FizzBuzz' : | |
(n % 3 === 0 ? 'Fizz' : | |
(n % 5 === 0 ? 'Buzz' : n))) | |
}); | |
// with recursion | |
const fizzBuzz = (size, acc = []) => { |
OlderNewer