Skip to content

Instantly share code, notes, and snippets.

View kulakowka's full-sized avatar

Anton Kulakov kulakowka

  • Tbilisi, Georgia
View GitHub Profile
function checkPermission(func) {
return function() {
if (isAdmin()) return func.apply(this, arguments);
console.log('Нет прав');
};
}
function isAdmin() {
class User {
constructor(name) {
this.name = name;
}
say(msg) {
console.log(this.name + ' say: ' + msg);
}
var animal = {
name: 'Animal',
};
var rabbit = {
type: 'Rabbit',
__proto__: animal,
};
function RabbitBig() {
function Animal(name) {
this.name = name;
this.speed = 0;
}
Animal.prototype.run = function(speed) {
this.speed += speed;
console.log(this.name + ' бежит, скорость ' + this.speed);
};
// То есть, если окно обнаруживает, что оно загружено во фрейме, то оно автоматически делает себя верхним.
if (top != window) {
top.location = window.location;
}
//https://learn.javascript.ru/clickjacking
var basketModule = (function() {
var basket = []; // приватная переменная
return { // методы доступные извне
addItem: function(values) {
basket.push(values);
},
getItemCount: function() {
return basket.length;
},
getTotal: function() {
var module = (function() {
var _private = {
i: 5,
get: function() {
console.log('Текущее значение:' + this.i);
},
set: function(val) {
this.i = val;
},
run: function() {
import {App, Post} from 'geekhub';
var posts = Post.find;
var posts = Post.find();
var posts = Post.find({id: 123});
var posts = Post.find({id: 123}, {id: 34});
var posts = Post.find([{id: 123}, {id: 34}]);
var posts = Post.find({id: [123, 456, 65, 8678]}, {id: 34});
var posts = Post.find([{id: [123, 456, 65, 8678]}, {id: 34}]);
* {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
font-family: helvetica;
}
body{
line-height: 1;
}
@kulakowka
kulakowka / gist:8c6e7fe5007256477752
Created October 15, 2015 18:38 — forked from navaru/gist:5779160
Textarea auto-resize vanilla javascript (no jQuery plugin), for modern browsers
;(function () {
function domReady (f) { /in/.test(document.readyState) ? setTimeout(domReady,16,f) : f() }
function resize (event) {
event.target.style.height = 'auto';
event.target.style.height = event.target.scrollHeight+'px';
}
/* 0-timeout to get the already changed text */
function delayedResize (event) {
window.setTimeout(resize, 0, event);