Skip to content

Instantly share code, notes, and snippets.

View AmilKey's full-sized avatar
🏠
Working from home

Ivan AmilKey

🏠
Working from home
View GitHub Profile
You can reset your branch to the state it was in just before the merge if you find the commit it was on then.
One way is to use git reflog, it will list all the HEADs you've had.
I find that git reflog --relative-date is very useful as it shows how long ago each change happend.
Once you find that commit just do a git reset --hard <commit id> and your branch will be as it was before.
@AmilKey
AmilKey / gist:cc68a8d105bce2a402d7
Created February 29, 2016 10:46
Ember.js 2.3 implement @each.property observer
The problem is that steps.[].stepStatus is not a valid dependent key anymore. You should replace it by steps.@each.stepStatus.
Here is a summary of valid and invalid dependent keys in current Ember versions:
array - this observes if the array reference itself changes, e.g replacing the entire array with another value or array such as that oldValue !== newValue.
array.[] - this observes both when the array itself changes (above) and when the array length changes (functionally equivalent of array.length)
array.@each.property - observes both cases above and when property of some of the array's items change
array.@each.{prop,anotherProp} - you can also observe multiple properties while specifying only one key. This expands to array.@each.prop and array.@each.anotherProp.
array.@each - isn't valid anymore, no trailing @each. Use .[] instead.
array.@each.property.property - Also not valid. Note that @each only works one level deep. You cannot use nested forms like todos.@each.owner.name or todos.@each.owner.@each
@AmilKey
AmilKey / javascript-query-string.js
Created February 26, 2016 07:23 — forked from DavidWells/javascript-query-string.js
JavaScript :: Regex trick: Parse a query string into an object
// http://stevenbenner.com/2010/03/javascript-regex-trick-parse-a-query-string-into-an-object/
// JavaScript regex trick: Parse a query string into an object
var queryString = {};
anchor.href.replace(
new RegExp("([^?=&]+)(=([^&]*))?", "g"),
function($0, $1, $2, $3) { queryString[$1] = $3; }
);
// Usage

fetch pull request locally: git fetch upstream refs/pull/{number}/head:{local_branch}

@AmilKey
AmilKey / gist:61068af43bd7963d7151
Created February 8, 2016 09:45
JSONSerializer ember data
`JSONSerializer` will normalize the JSON payload to the JSON API format that the
Ember Data store expects.
You can customize how JSONSerializer processes its payload by passing options in
the `attrs` hash or by subclassing the `JSONSerializer` and overriding hooks:
- To customize how a single record is normalized, use the `normalize` hook.
- To customize how `JSONSerializer` normalizes the whole server response, use the
`normalizeResponse` hook.
- To customize how `JSONSerializer` normalizes a specific response from the server,
use one of the many specific `normalizeResponse` hooks.
- To customize how `JSONSerializer` normalizes your id, attributes or relationships,
@AmilKey
AmilKey / gist:cb9be3ddcd3b1ed8c799
Created December 14, 2015 20:04
Router Request Lifecycle
http://blog.trackets.com/2013/02/08/router-request-lifecycle.html
Router Request Lifecycle
enter (private)
activate - executed when entering the route
deserialize (private)
model (formely deserialize) - takes the params and returns a model which is set to the route's currentModel
serialize - used to generate dynamic segments in the URL from a model
setupController - takes currentModel and sets it to the controller's content by default
renderTemplate - takes current controller and what model returns and renders the template with an appropriate name
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
vehicle: '',
vehicles: [1,2,3],
});
@AmilKey
AmilKey / gist:a738e4f6622dab93dfdc
Created December 9, 2015 08:04
computed property with Promise
delegate methods to proxy object
proxyToContent = (method) ->
->
content = Ember.get(@, 'content');
content[method].apply(content, arguments)
appointment: Ember.computed 'pet.id', ->
appointment = Promise()
@AmilKey
AmilKey / gist:ed35f2c7c081f48b7009
Created December 6, 2015 12:04
COMPONENT LIFECYCLE HOOKS Ember 2.0
COMPONENT LIFECYCLE HOOKS
A number of new component lifecycle hooks have been introduced to Ember 1.13. Using these hooks allows you to write data down, action up (DDAU) style components today, despite the two-way data binding of curly components.
On first render (in order):
didInitAttrs runs after a component was created and passed attrs are guaranteed to be present. In Ember 1.13, the attributes will be available as this.get('attrName').
didReceiveAttrs runs after didInitAttrs, and it also runs on subsequent re-renders, which is useful for logic that is the same on all renders. It does not run when the component has been re-rendered from the inside.
willRender runs before the template is rendered. It runs when the template is updated for any reason (both initial and re-render, and regardless of whether the change was caused by an attrs change or re-render).
didInsertElement runs after the template has rendered and the element is in the DOM.
@AmilKey
AmilKey / gist:296590f565037c5ef76a
Last active July 10, 2019 07:49
Процесс обработки WEB-страницы браузером
Процесс обработки WEB-страницы браузером
Для начала, рассмотрим последовательность работы браузера при отображении документа:
Из полученного от сервера HTML-документа формируется DOM (Document Object Model).
Загружаются и распознаются стили, формируется CSSOM (CSS Object Model).
На основе DOM и CSSOM формируется дерево рендеринга, или render tree — набор объектов рендеринга (Webkit использует термин «renderer», или «render object», а Gecko — «frame»). Render tree дублирует структуру DOM, но сюда не попадают невидимые элементы (например — <head>, или элементы со стилем display:none;). Также, каждая строка текста представлена в дереве рендеринга как отдельный renderer. Каждый объект рендеринга содержит соответствующий ему объект DOM (или блок текста), и рассчитанный для этого объекта стиль. Проще говоря, render tree описывает визуальное представление DOM.
Для каждого элемента render tree рассчитывается положение на странице — происходит layout. Браузеры используют поточный метод (flow), при котором в большинс