Skip to content

Instantly share code, notes, and snippets.

@maestrow
maestrow / CrtlZ.coffee
Last active August 29, 2015 13:58
nodejs: Processing Ctrl+Z in stdin on Windows
compare = (buf1, buf2) ->
return false if buf1.length != buf2.length
for i in [0...buf1.length]
return false if buf1[i] != buf2[i]
true
isCtrlZ = (chunk) -> compare chunk, [26,13,10]
input = (cb) ->
result = ''
@maestrow
maestrow / GenericUtils.coffee
Last active August 29, 2015 14:00
Generic helper methods and techniques that can be useful in every project.
isArray = (x) ->
typeof x is 'object' and x.constructor is Array
Array::last = -> @[@length - 1]
@maestrow
maestrow / git-checkout-from-a-specific-directory.sh
Created July 24, 2014 08:44
Git checkout from a specific directory
# http://stackoverflow.com/questions/17833185/git-checkout-from-a-specific-directory
# Method №1
mkdir <repo.git>
mkdir <working-dir>
git clone <repo-url> <repo.git> --bare --depth 1
git --git-dir=<repo.git> --work-tree=<working-dir> checkout HEAD -- <repo-subdir>
# Method №2
mkdir <working-dir>
@maestrow
maestrow / git-workflow.sh
Last active March 31, 2018 12:41
git-workflow
git init
git remote add origin https://github.com/try-git/try_git.git
git status
git add --all
git commit -am "initial commit"
git push -u origin master
@maestrow
maestrow / requirejs-cheatsheet.md
Last active August 29, 2015 14:04
Requirejs Cheat Sheet
@maestrow
maestrow / Cakefile
Created August 3, 2014 20:32
Modular Cakeflle
# http://www.mikedellanoce.com/2013/04/coffeescript-tip-modular-cakefile.html
fs = require('fs')
tasks = fs.readdirSync('tasks')
require('./tasks/' + task.replace(/\.coffee$/, '')) for task in tasks
@maestrow
maestrow / repository.md
Last active May 1, 2024 06:26
Паттерн репозиторий

Паттерн репозиторий

Репозиторий - это слой абстракции, инкапсулирующий в себе всё, что относится к способу хранения данных. Назначение: Разделение бизнес-логики от деталей реализации слоя доступа к данным.

Паттерн Репозиторий стал популярным благодаря DDD (Domain Driven Design). В противоположность к Database Driven Design в DDD разработка начинается с проектирования бизнес логики, принимая во внимание только особенности предметной области и игнорируя все, что связано с особенностями базы данных или других способов хранения данных. Способ хранения бизнес объектов реализуется во вторую очередь.

Применение данного паттерна не предполагает создание только одного объекта репозитория во всем приложении. Хорошей практикой считается создание отдельных репозиториев для каждого бизнес-объекта или контекста, например: OrdersRepository, UsersRepository, AdminRepository.

Пример

MongoDB is:

  • JSON storage
  • schemaless
  • NOT support SQL

Functionality that missing in MongoDB (in order to retain scalability):

  • Joins between collections
  • Transactions across multiple collections
@maestrow
maestrow / repo-naming-conventions.md
Last active August 1, 2023 09:24
Соглашение об именовании репозиториев

Общие правила

Рассмотрим произвольный проект с именем "Some Cool Project". Варианты имени репозитория для данного проекта:

  1. somecoolproject
  2. SomeCoolProject
  3. some-cool-project
  4. some_cool_project
  5. Some-Cool-Project