Skip to content

Instantly share code, notes, and snippets.

View Ormadont's full-sized avatar

Evgeniy Pavlovich Demyanov Ormadont

  • Krost
  • Moscow, Russia
View GitHub Profile
@gschema
gschema / intro.md
Last active November 27, 2023 04:35
Basic JavaScript MVC Implementation

Basic JavaScript MVC Implementation

Despite being derived from classical MVC pattern JavaScript and the environment it runs in makes Javascript MVC implementation have its own twists. Lets see how typical web MVC functions and then dive into simple, concrete JavaScript MVC implementation.

How Web MVC typically works

Typical server-side MVC implementation has one MVC stack layered behind the singe point of entry. This single point of entry means that all HTTP requests, e.g. http://www.example.com or http://www.example.com/whichever-page/ etc., are routed, by a server configuration, through one point or, to be bold, one file, e.g. index.php.

At that point, there would be an implementation of Front Controller pattern which analyzes HTTP request (URI at first place) and based on it decides which class (Controller) and its method (Action) are to be invoked as a response to the request (method is name for function and member is name for a variable when part of the class/object).

@grimzy
grimzy / git-pull-all
Created September 15, 2017 02:15
Git pull all remote branches
#!/usr/bin/env bash
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
@neretin-trike
neretin-trike / pug.md
Last active July 25, 2024 15:54
Туториал по HTML препроцессору Pug (Jade)
@Ormadont
Ormadont / objectToPrimitive.js
Last active August 27, 2021 08:53
JS: transform object to primitive
function transform(hint) {
return hint == 'string' ? this.name : this.height
}
let man = {
name: 'Evgeniy',
height: 185,
[Symbol.toPrimitive]: transform
}