Skip to content

Instantly share code, notes, and snippets.

Avatar
🐳

Stanislav Kondratiev technobulka

🐳
View GitHub Profile
@technobulka
technobulka / days_count.js
Last active Aug 29, 2015
Get days count by month and year.
View days_count.js
function(m,y){return 31-((m==2)<<!(!(y%400^y%100)&!(y%4)))-(m-1)%7%2}
@technobulka
technobulka / next-prev-by-circle.js
Created Sep 16, 2013
Next/prev list item by circle
View next-prev-by-circle.js
var c = 9, // current, start from length-1
l = 10, // length
i; // index, 0 - prev, 1 - next
c = i?++c%l:~--c%l?c%l:l-1;
View num_end.js
function numEnd(n,t){return t[n%100>4&&n%100<20?2:'201112'[n%10<5?n%10:5]]}
// test
var a = [1, 2, 5, 10, 20, 21, 22],
i = 0;
for (i in a) {
console.log(a[i] + ' котик' + numEnd(a[i], ['', 'а', 'ов']));
}
View cookie.js