Skip to content

Instantly share code, notes, and snippets.

let users = [
{id: 1, name: 'user1', status: 'online'},
{id: 2, name: 'user2', status: 'offline'},
{id: 3, name: 'user3', status: 'invisible'}
]
let updatedUser = {id: 4, name: 'user2', status: 'lalala'}
let index = -1;
let oldItems = users;
let newItems = [];
@melnik88
melnik88 / gist:edb162dd24014e3db110fca2876affe2
Created September 1, 2016 18:15
Измерение производительности javascript-функций
function fib3(value){
if(value === 1) return 1
if(value === 2) return 1
if(value > 2) {
return fib3(value - 1 ) + fib3(value - 2)
}
}
let t0 = performance.now();
result = fib3(30);
let t1 = performance.now();
@melnik88
melnik88 / index.js
Created February 23, 2016 18:45
backbone show popup
var App = Backbone.View.extend({
el: $('#app'),
popapStatus: 'hidden',
initialize: function() {
var popapView = new PopapView(),
buttonView = new ButtonView();
@melnik88
melnik88 / gist:a3c071bff5de9a439ed7
Created January 9, 2016 19:21
backbone template
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script src="http://documentcloud.github.com/underscore/underscore-min.js">
@melnik88
melnik88 / gist:9618006
Created March 18, 2014 11:08
create single class
var someClass = function(){
function init(){
console.log('someClass is created')
}
this.init = init;
}
var myclock = new someClass();
myclock.init();
$(window).load(function() {
var countArray = [100,54,13]
var counter = 0
$('.social-likes__counter').not(".social-likes__counter_twitter").each(function(){
var num = $(this).text()
var num2 = parseInt(num) + countArray[counter]
$(this).text(num2)
counter++
})
})