Skip to content

Instantly share code, notes, and snippets.

View technobulka's full-sized avatar
🐳

Stanislav Kondratiev technobulka

🐳
View GitHub Profile
@technobulka
technobulka / next-prev-by-circle.js
Created September 16, 2013 11:24
Next/prev list item by circle
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;
@technobulka
technobulka / num_end.js
Last active October 13, 2015 23:48
Numeral Ends
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], ['', 'а', 'ов']));
}
@technobulka
technobulka / cookie.js
Created December 7, 2012 06:12
JS: Cookie
@technobulka
technobulka / days_count.js
Last active August 29, 2015 14:05
Get days count by month and year.
function(m,y){return 31-((m==2)<<!(!(y%400^y%100)&!(y%4)))-(m-1)%7%2}