Skip to content

Instantly share code, notes, and snippets.

View AlexKotel's full-sized avatar

Alexander Kotelnikov AlexKotel

View GitHub Profile
window.open('http://ravenfox.ru', 'FuckYeah', 'width=500, height=300,resizable=no,scrollable=no,directiries=no,location=no,toolbar=no,menubar=no,status=no')
function writeFile(content, name) {
name = name || 'filename.txt';
var a = document.createElement('a');
a.hidden = '';
a.href = 'data:text/json,' + encodeURIComponent(content);
a.download = name;
a.textContent = 'Download file '+name+'!';
console.log(a);
document.body.appendChild(a);
}
@AlexKotel
AlexKotel / numberBeautyfiler.js
Last active July 28, 2016 11:11
Разделение разрядов числа пробелами
// Разделение разрядов числа пробелами.
var str = 'Lorem ipsum 234456234 Lorem ipsum 7345287346 asdfae';
str.replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ');
@AlexKotel
AlexKotel / ext.method.coffee
Last active August 29, 2015 14:05
Extract method from object: x.y(z) -> y(x,z)
#Extract method from object
# Положим в ПЕРЕМЕННУЮ slice ФУНКЦИЮ slice из прототипа объекта Array
slice = Array.prototype.slice
# Используем call или apply, чтобы предоставить контекст (this) для функции slice
slice.call([1,2,3], 0, 1) # => [1]
slice.apply([1,2,3], [0,1]) # => [1]
# Т.к. call - это метод объекта Function, это значит, что контекстом метода call является вызывающая его функция
@AlexKotel
AlexKotel / window.load.js
Last active March 1, 2018 11:21
Load to page js by ULR
window.loadScript = function (url) {
var script = document.createElement("script");
script.src = url;
document.head.appendChild(script);
}
window.loadStyle = function (url) {
var link = document.createElement("link");
link.href = url;
document.head.appendChild(link);