Skip to content

Instantly share code, notes, and snippets.

@monochromer
monochromer / self-invoke-constructor.js
Last active August 29, 2015 14:21
Конструкторы, вызывающие сами себя
function myObject () {
if ( !(this instanceof myObject) ) {
return new myObject();
}
}
angular.module("app", []).controller("ctrl", function($scope){
$scope.options = [
{value:'Option1', selected:true},
{value:'Option2', selected:false}
];
$scope.toggleAll = function() {
var toggleStatus = !$scope.isAllSelected;
angular.forEach($scope.options, function(itm){ itm.selected = toggleStatus; });
@monochromer
monochromer / animation-end-better.js
Last active August 29, 2015 14:23
Улучшение события окончания анимации
/*
By Osvaldas Valutis, www.osvaldas.info
Available for use under the MIT License
*/
;( function ( document, window, index ) {
var s = document.body || document.documentElement, s = s.style, prefixAnimation = '', prefixTransition = '';
if( s.WebkitAnimation == '' ) prefixAnimation = '-webkit-';
if( s.MozAnimation == '' ) prefixAnimation = '-moz-';
@monochromer
monochromer / index.html
Last active December 21, 2023 21:56
Простой шаблон для html/css/js
<!DOCTYPE html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--[if lt IE 8]><html class="no-js ie ltie8 ltie9 ltie10" lang="ru"><![endif]-->
<!--[if IE 8]><html class="no-js ie ie8 ltie9 ltie10" lang="ru"><![endif]-->
<!--[if IE 9]><html class="no-js ie gtie8 ie9 ltie10" lang="ru"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html class="no-js" lang="ru"><!--><![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
// пример модуля
Core.register('module-name', function(sandbox) {
return {
init: function() {
// constrictor
if (sandbox.testSomething()) {
console.log('yes, you can!');
}
},
@monochromer
monochromer / .editorconfig
Last active November 9, 2015 08:26
Пример файла editorconfig
# http://editorconfig.org
# парсер не будет искать другие конфиги родительских папках
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
.ps-container {
position: relative;
-ms-touch-action: none;
overflow: hidden !important;
}
.ps-container.ps-in-scrolling {
pointer-events: none;
}
.ps-container.ps-active-x > .ps-scrollbar-x-rail,
[user]
name = user
email = user@example.com
[http]
proxy = http://127.0.0.1:8080
[https]
proxy = https://127.0.0.1:8080
[filter "hawser"]
clean = git hawser clean %f
smudge = git hawser smudge %f
@monochromer
monochromer / index.html
Created January 24, 2016 15:56
Простой пример observable
<input type="text" id="a-text">
+
<input type="text" id="b-text">
=
<input type="text" id="c-text" readonly>