This file contains hidden or 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
String.prototype.replaceAll = function(find, replace) { | |
if(typeof find === 'string') | |
return this.split(find).join(replace); | |
var str = this; | |
find.forEach(function(el, i){ | |
str = str.split(el).join(replace[i]); | |
}); |
This file contains hidden or 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
-- 1. Создаем временную таблицу с правильными записями | |
CREATE TABLE tmp_users | |
SELECT * FROM users AS u | |
GROUP BY u.login | |
HAVING COUNT(u.login) >= 1 | |
-- 2. Переносим данные из tmp_users в users | |
-- предварительно очистив users | |
INSERT INTO users | |
SELECT * FROM tmp_users |
This file contains hidden or 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
({ | |
css: function(el, prop){ | |
/*return css-prop*/ | |
}, | |
ajax: function(options){ | |
/*make ajax-request*/ | |
}, | |
init: function(name){ | |
var cache = {}; | |
this.getCache = function(){ return cache }; |
This file contains hidden or 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 age = 'think'; | |
switch (true) { | |
case (/think/g).test(age): | |
console.log("Think!"); | |
break; | |
default: | |
console.log("not found"); | |
break; | |
}; |
This file contains hidden or 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 Field = function(selector){ | |
var el = document.querySelector(selector), | |
callback; | |
this.get = function() { | |
return el.value; | |
}; | |
this.set = function(val) { |
This file contains hidden or 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 $scope = (function($){ | |
var _this = { | |
name: 'Alex' | |
}; | |
return { | |
get: function(prop){ | |
return _this[prop]; | |
}, | |
set: function(prop, val){ | |
return _this[prop] = val; |
This file contains hidden or 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
Array.prototype.remove = function(id){ | |
return this.splice(id, 1); | |
} | |
var a = ["a","b","c","d"]; | |
a.remove(2); | |
console.log(a); | |
// ["a", "b", "d"] |
This file contains hidden or 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 player = { | |
play: function(music){ | |
console.info('player plaing: ', music); | |
} | |
}; | |
var search = { | |
items: { | |
a: 'ABBA', | |
b: 'Boney M', |
This file contains hidden or 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 isMobile = function(){ | |
return /Mobi|Mini|Symbian|SAMSUNG|Nokia|BlackBerry|Series|Bada|SymbOS|PLAYSTATION/g | |
.test(navigator.userAgent.toString()); | |
}; |
OlderNewer